Wednesday, August 24, 2011

How to 301 Redirect permannent By SEO POINT

0 comments
According to SEO POINT How to redirect URL

301 non-www to www

RewriteEngine On
ErrorDocument 401 http://wwww.example.com/
ErrorDocument 404 http://www.example.com/
RewriteRule ^index.htm$ http://www.example.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

You have only to put 'RewriteEngine On' once at the top of your .htaccess file.

This symbol ^(*.)$' says that we'll take anything that comes after http://example.com and append it to the end of 'http://www.example.com' (that is the '$1' part) and redirect to that URL. For more grit on how this works checkout a good regular expressions resource or two.



301 www to non-www

Finally www 301 redirect to non-www version would look like:


RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Redirect a Dynamic URL to a New Single HTML page :-

It's common that one will need to redirect dynamic URL's with parameters to single
static file ( HTML Page):

RewriteRule ^article.php?id=(.*)$ /article.htm [L,R=301]

In the above example, a request to a dynamic URL such as http://www.example.com/article.php?id=anynumber will be redirected to http://www.example.com/article.htm




Leave a Reply

Related Posts Plugin for WordPress, Blogger...