BeOnTOP, an Official Google Partner Russian +971 4 554 7316 Open
 
Home page About Blog Setting up a 301 redirect via htaccess

Setting up a 301 redirect via htaccess

The main error when promoting a website is wrong setting up of 301 redirects.
In what cases, you need to use redirection?

  1. The main page should have only one main writing. For example: http://www.beontop.ae/

All others must forward to this one. It is necessary set up a 301 redirect from http:// beontop.ae/ to http://www. beontop.ae/

  1. When we changed the URL of the page. We do this in order not to lose position or influence of external links to the old URL, so we need to do a redirect from the old URL to the new one.
  2. If we have the same page at multiple URL’S. This happens in almost all free and commercial CMS.

Setting up a 301 redirect from without www to www

Go to the FTP of your website and find the htaccess file there. If you can’t find it, then create a new one. Open this file using any text editor and insert the following lines:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain\.ae$ [NC]
RewriteRule ^(.*)$ http://www.domain.ae/$1 [R=301,L]

Setting up a 301 redirect from www to without www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.ae$ [NC]
RewriteRule ^(.*)$ http://domain.ae/$1 [R=301,L]

301 redirect from the old URL to the new one

RewriteRule ^old.html$ new.html [R=301,L]

Setting up redirect when changing domain name

If a new domain has “www”

RewriteEngine On
RewriteCond %{HTTP_HOST} !^newdomain\.ae$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.ae/$1 [R=301,L]

If a new domain doesn’t have “www”

RewriteEngine On
RewriteCond %{HTTP_HOST} !^newdomain\.ae$ [NC]
RewriteRule ^(.*)$ http://newdomain.ae/$1 [R=301,L]

Comments 1

Asim #1 12.12.2016 at 16:24 pm

If I need setup redirection, I always use this page. Thank you!

What do you think about it?

Go Up