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

Rating: 2.7/5
Views: 1753


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


Output generated by ProSupport
Copyright © 2024 ProPanelSystems.com - ProSupport v0.9.1 Rev. 1