Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

www to no-www, and vice-versa (See related posts)

To redirect requests for www.example.com to example.com (without the www) put this in your .htaccess:

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


And to do the reverse (redirect non-www to www), try this:

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


You need to create an account or log in to post comments to this site.


Related Posts