Apache .htaccess - Redirect www to non-www or vice versa

Redirect www to non www properly (wildcard / any hostname)

RewriteEngine On RewriteBase /

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

 

Redirect www.example.com to example.com (with hostname):

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com [NC]

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

 

Redirect example.com to www.example.com (with hostname):

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]

RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

 

 

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare