What am I doing wrong with my .htaccess file?

Discussion in 'Apache' started by MortimerJazz, Jul 3, 2008.

  1. #1
    I'm trying to write a 301 re-direct for my site, so that http://mysite.co.uk, http://mysite.co.uk/index.html and http://www.mysite.co.uk/index.html all re-direct to http://www.mysite.co.uk ... and while I've had it working on one site, I can't seem to ammend it to get to work with a new site I've been working on.

    Does it have something to do with the length of the domain name?

    Anyway, here's the code I'm trying to use:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.(.*)
    RewriteRule ^(.*)$ http://www.mysite.co.uk/$1 [R=301,L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
    RewriteRule ^index\.html$ http://www.mysite.co.uk/ [R=301,L]
    Code (markup):
     
    MortimerJazz, Jul 3, 2008 IP