Results 1 to 1 of 1

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

  1. #1
    Matt's Avatar
    Matt is offline GlowHost Administrator
    Join Date
    Jan 2005
    Location
    Behind your monitor
    Posts
    6,208

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

    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 (.*) http://www.yourdomain.com/$1 [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]
    Last edited by Matt; 04-22-2010 at 08:03 PM.
    Send your friends and site visitors to GlowHost and get $125 plus bonus!
    GlowHost Affiliate Program | Read our Blog | Follow us on X |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14