20i Reseller Hosting

.htaccess global redirect issue

Discussion in 'Scripts and Coding' started by theonemanyuri, Jul 5, 2013.

Thread Status:
Not open for further replies.
  1. theonemanyuri

    theonemanyuri Active Member

    Joined:
    Jun 2010
    Posts:
    556
    Likes Received:
    2
    I'm having some problems with my .htaccess global redirect. I just want to direct example.com to www.example.com. My usual way of doing this in .htaccess didn't work so I changed it slightly to the suggested code from the hosting company:

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

    Is the code alright? Is it possibly something server side stopping it from working? Any help much appreciated, it's not really my forte...
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
    articles.co.uk
     
  3. Admin

    Admin Administrator Staff Member

    Joined:
    Jun 2004
    Posts:
    10,861
    Likes Received:
    323
    Code:
    //Rewrite to www
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com[nc]
    RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]
     
  4. Systreg Ireland

    Systreg Well-Known Member

    Joined:
    Oct 2008
    Posts:
    7,403
    Likes Received:
    214
    I was given this by someone on here, note the bit about saving in the file in lowercase, rather than capitals that I did, see post #7:

    http://www.acorndomains.co.uk/scripts-coding/98067-htaccess-help.html

    Which did the trick for me:

     
    Last edited: Jul 5, 2013
  5. theonemanyuri

    theonemanyuri Active Member

    Joined:
    Jun 2010
    Posts:
    556
    Likes Received:
    2
    Still no joy, could need time to update I guess..?
     
  6. Admin

    Admin Administrator Staff Member

    Joined:
    Jun 2004
    Posts:
    10,861
    Likes Received:
    323
    No if you are typing both the URLs in your browser the redirect would be instant.

    PM site details if you want me to take a look.

    Admin
     
  7. theonemanyuri

    theonemanyuri Active Member

    Joined:
    Jun 2010
    Posts:
    556
    Likes Received:
    2
  8. theonemanyuri

    theonemanyuri Active Member

    Joined:
    Jun 2010
    Posts:
    556
    Likes Received:
    2
    Just to update this for anyone reading, .htaccess isn't allowed on a 50webs free account, so not a code issue...
     
Thread Status:
Not open for further replies.