Support Central » Knowledgebase » Knowledgebase Article Not logged in. Login
 
Announcements

Knowledge Base

Submit a Ticket

Client Login
Article » [How To] Redirect all requests to the www version of your site using mod_rewrite

Rating:
Was this article helpful? YES NO MODERATELY
Views: 1749
Printable Version


Here is another one that will allow you to make all requests to your site have "www" in front of it.

All sites we host by default can be accessed with and without the www, but some of you would like "www" only style urls.

CODE:
 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) [url=http://www.yourdomain.com/$1]http://www.yourdomain.com/$1[/url] [R=301,L]



In Apache 2.x you might try:
CODE:
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www.yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]



Follow-up and discuss this topic in our forums
Help Desk Powered By ProSupport v0.9.1