Thursday, January 20, 2011

htaccess to strip WWW from domain *and* any subdirectories

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

Am running the above code and it strips the www when you go to http://www.mydomain.com but how do I get it to also strip the www when you go to a subdirectory, etc http://www.mydomain.com/users ?

  • You might want to enable

    RewriteLog "yourLogFile"
    RewriteLogLevel 3
    

    to get some more information about what is going on ...

    From Dominik

0 comments:

Post a Comment