HTACCESS 301 redirect not working

Discussion in 'Apache' started by murtuza.hasan, Sep 16, 2009.

  1. #1
    i am new to htaccess. I have been using the following code to perform 301 redirect:

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

    This is not working correctly in all browser. I am using firefox,IE,Flock and Safari. This is not working in IE. Also in few other computers, its not working in firefox or any other browser.

    I am looking for a solution badly. Please help

    Thanks
     
    murtuza.hasan, Sep 16, 2009 IP
  2. ayyappansan

    ayyappansan Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try to use the follow code and have a try.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
     
    ayyappansan, Sep 17, 2009 IP
  3. murtuza.hasan

    murtuza.hasan Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks guys, but unfortunately none of them worked. I wonder whether it has nething to do with the server configuration. i have tried almost everything for this. but with no success. :confused:
     
    murtuza.hasan, Sep 18, 2009 IP
  4. ayyappansan

    ayyappansan Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try to use the follow code and have a try.
    In httpd.conf

    LoadModule rewrite_module modules/mod_rewrite.so
    and also
    Is AllowOverride set to All in your httpd.conf? Like this:

    AllowOverride All

    IN .htaccess
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
     
    ayyappansan, Sep 19, 2009 IP