301 redirect

This article will show you how to create a redirect using your .htaccess file.

If you’ve recently moved your website to a different URL, you can set up a 301 redirect to ensure that anyone going to your old site is automatically taken to your new one.

What is a 301 redirect?

Simply put, a 301 redirect is a HTTP status code that is sent to a browser from a web server, to indicate that a page has permanently moved. Any links that include your old URL will then redirect to the new URL that has been provided. You can also redirect a www version of your site to a non-www. version.

If you don’t have a 301 redirect in place, anyone visiting your old URL will be greeted with an error message, which will have a negative impact on your credibility as well as your SEO ranking.

To set up a 301 redirect, simply follow the instructions below:

Step 1 of 4

Open a text editor such as Notepad.

 

 

Step 2 of 4

Copy the following line of code into your text editor, replacing http://www.example.com/ with the URL you wish to forward your domain name to.

Redirect 301 / http://www.example.com/

If, however, you want to redirect www to a non-www version of your site, then copy the following line of code into your text editor, replacing example.com and http://www.example.com/ with your new URL.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
Step 3 of 4

Save the file as .htaccess.

 

Step 4 of 4

Upload the file to your webspace by using an FTP client