Search This Blog

Tuesday, October 20, 2015

How to create a 301 Redirect

Step1:

Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com

The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

 Step2:

To rewrite we should on the RewriteEngine on

Syntax:

RewriteCond %{HTTP_HOST} !^www\.starevents\.in
RewriteRule (.*) http://www.starevents.in/$1 [R=301,L]

sample code

 .htaccess.file:

RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^www\.starevents\.in
RewriteRule (.*) http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.htm
RewriteRule ^(.*)index.htm$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.pl
RewriteRule ^(.*)index.pl$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/default\.htm
RewriteRule ^(.*)default.htm$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/default\.aspx
RewriteRule ^(.*)default.aspx$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.aspx
RewriteRule ^(.*)index.aspx$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.asp
RewriteRule ^(.*)index.asp$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/default\.asp
RewriteRule ^(.*)default.asp$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.shtml
RewriteRule ^(.*)index.shtml$ http://www.starevents.in/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.cfm
RewriteRule ^(.*)index.cfm$ http://www.starevents.in/$1 [R=301,L]

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

ErrorDocument 404 http://www.starevents.in/404.html

 Step3:

SEO Redirect checker to check 301 is redirecting

http://www.ragepank.com/redirect-check/

Step 4:

Enjoy Folks

No comments:

Post a Comment

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...