Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble redirecting non www urls to www

    I'm trying to make non www urls to my site redirect to www urls. When I place the command below (replacing mysite.com with my actual domain of course) in the .htaccess my site cannot be accessed at all.

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

    My hosting service told me to try this one and it caused a 500 error.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com[nc]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]

    Any ideas on what could be causing this?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    I'm trying to make non www urls to my site redirect to www urls.
    Try
    Code:
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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