How do I setup a 301 redirection?

September 13, 2017     0 comments

Sometimes we need to change the URL of pages, but it is a risky task, because if your pages are already indexed in search engines, you will lose not only visitors but also your SEO ranking. Your indexed URLs will start to disappear one by one, forcing you to start from scratch again

If you need to change the URL of a page as it is shown in search engine results, we recommend that you use a 301 redirect. This is the best search engine and user-friendly way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.

You can do it in your cPanel, in your .htaccess file, or in your php file. To perform a 301 redirect in your cPanel, under the Domains heading click on Redirects.

Fill in the information required for the redirection, and you are done.

Select the Wildcard Redirect option if you wish to redirect all files within a directory to the same filename in the new directory. For example, if you enable the Wild Card Redirect option and redirects to, then a visitor who tries to access the URL redirects to the URL.

To do a 301 redirection in your PHP file, put in this code in the old page:

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location:" );

To do a 301 redirection in your .htaccess file, you may add in the following codes:

Redirect an old page URL to a new page URL:

Redirect 301 /old-page/

Redirect root domain to new domain:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC,OR]
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule (.*)$$1 [R=301,L]

How helpful was this article to you?

Leave a comment

Your name
Your email address
Comment on this article
Powered by