Search engine friendly rewrite rule

In case of you want to map multiple domains to one web site, or you changed your domain, and you wand to avoid Google indexing issues, you need to permanent redirect with HTTP 301 code.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.old-domain.de$ [NC]
RewriteRule ^.*$ http://www.new-domain.de%{REQUEST_URI} [R=301,L]

Rewriting URL’s without a leading „www“ to the same URL with www-prefix is possible on the same way:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^my-domain.de$ [NC]
RewriteRule ^.*$ http://www.my-domain.de%{REQUEST_URI} [R=301,L]

Note: mod_rewrite must be enabled to make this code work.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.