301 redirect doesn't work?

by DavidO
3 replies
  • SEO
  • |
I'm trying to redirect my root domain to the www version using this code in .htaccess:

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

(Of course I replaced example with my domain name!)

It worked for a few minutes and then stopped redirecting. I've tried several other versions of the redirect but nothing works.

The fact that it started out working tells me the code is correct but there must be something else conflicting with it.

I also tried to redirect my index.html page to the root domain with equal lack of success.

My .htaccess file has this pre-existing code and I wonder if anything here is causing the problem:

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName "control-your-blood-pressure.com"
AuthUserFile /users4/data/c/controly-07386/public_html/_vti_pvt/service.pwd
AuthGroupFile /users4/data/c/controly-07386/public_html/_vti_pvt/service.grp
#301 #redirect #work
  • Profile picture of the author Mark Brian
    The pre-existing code is usually for Frontpage extensions that are not generally used. Try removing it and just leave your code but back it up just in case things go wrong.
    It should not cause any problems without it if you're not using Frontpage extensions
    Signature

    {{ DiscussionBoard.errors[847791].message }}
  • Profile picture of the author DavidO
    Thanks, Mark. I already tested it with only the redirect code and no luck. I've confirmed that I'm on a Linux/Unix server too.

    I've checked the redirect code from serveral sources and it's got to be correct.
    {{ DiscussionBoard.errors[847800].message }}
  • Profile picture of the author Mark Brian
    Hmm.. try adding this on top:

    RewriteEngine On
    Signature

    {{ DiscussionBoard.errors[847808].message }}

Trending Topics