Thursday, 7 September 2017

Redirect Url on Htaccess

This article will teach you how to use an Htaccess (Hypertext Access) file to redirect a web page or domain name. Using Htaccess Redirect is the best way of redirect when it comes to Search Engine Optimization.
Redirect Url on Htaccess
Redirect Url on Htaccess

The Htaccess file is actually the name of the Apache file configuration located on every level of the folder. All code in Htaccess is a command for that folder including sub-subfolders where Htaccess is located. This method can not be used on a windows based server, and if you do not find this file on a linux-based server then you can create it.

The 301 redirect method is the best and fastest method for server configuration. The web server will check the Htaccess file before loading the web page, so if the server does a 301 redirect page then the page will be visible faster. Search Engines also use a 301 redirect to find where new pages are placed.

Here are the Htaccess 301 redirect codes that you can use for specific situations. As a last note, do not forget to back up before you change the code inside Htaccess and make sure to use ASCII format. Make sure you also change the domain name according to your domain name.

Redirect One Specific Page
Example: redirect 301 /webpage.html

The above code will redirect one page to another. the italicized code is the old page Url address and the bold code is the new page Url. Put this code in the Htaccess file located in the root folder.

Redirect Domain Name
Example: redirect 301 / http: //
The above code is used to redirect the domain. Suppose you have a domain who wants to be directed to the new domain then you should put the above code on the root folder domain. If any visitor to the address it will soon be transferred to the domain

Redirect to
RewriteEngine On
Options + FollowSymLinks
RewriteCond% {THE_REQUEST} ^ [A-Z] {3, 9} \ /.* index \ .php \ HTTP /
RewriteRule ^ index \ .php / $ 1 [R-301, L]

Redirect to
RewriteEngine On
RewriteRule ^ $ / blog / [R = 301]

The above code will perform a 301 redirect to a specific folder. This code is commonly used to redirect visitors to another page when index.html on root is in repair. Can also be used if you make a mistake installation of blog or e-commerce on subfolder in root folder. The bold code is the name of the folder to which you are headed.

see video related to this post, sourced from