URL Redirection Method in SEO (301, 302 and 307)

There are several reasons to use URL redirection:

  1. Moving a old site to new domain
  2. URL Shortening
  3. Mis-type a URL
  4. Search Engine Manipulation ( Canonical )
  5. Manipulating visitors

The HTTP standard defines several status codes for redirection methods:

  • 300 – multiple choices redirection
  • 301 – moved permanently
  • 302 – temporary redirect ( used to specify redirection for unspecified reason)
  • 307 – temporary redirect

Redirect using .htaccess :

Redirect to old Domain website to new domain website:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.:]+.)*olddomain.com.?(:[0-9]*)?$ [NC]
RewriteRule ^(.*)$ [R=301,L]
———————————————————————————————–
301 Redirection from www to non-www site:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain.com
RewriteRule (.*) [R=301,L]
———————————————————————————————–
301 Redirection from non-www to www site:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ [L,R=301]
———————————————————————————————–
Now Google provides the solutions for canonical issues for adding meta tag,
<link rel=”canonical” href=”http://www.preferreddomain.com”>
Moving a old site to new domain
URL Shortening
Mis-type a URL
Search Engine Manipulation
Manipulating visitors
Scroll to Top