Thursday, March 25, 2010

Permanent redirect with Apache Mod rewrite

Yesterday, I set up a permanent redirect for my personal site on to redirect all requests without leading www using Apache Mod rewrite and RewriteCondition and RewriteRule.

Here's my snippet that I'm using
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^/(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L]

Someone may ask why I should do that?
The simple answer: SEO

Search engines are crawling the web to indexing content of web pages. So if they discover links to they are not seen as a reference to the same content reachable through

That's all.

Good german resource explains redirection: Automatische Weiterleitung

No comments:

Post a Comment