Reputation: 16749
I try to redirect all requests on any URI with a www to the same URL without www. So
The rules I'm using at the moment are
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
</IfModule>
But it only seems to work on the main domain, not on subpages.
Also important: Other subdomains like static.domain.com should still work.
Thanks for your help!
Upvotes: 1
Views: 570
Reputation: 954
Try this :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
Upvotes: 0
Reputation: 785156
Try this rule with %{REQUEST_URI}
instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(domain\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301,NE]
Upvotes: 1