Problem with .htaccess - why does this not 301 redirect properly?

Discussion in 'Apache' started by Michaels-r, Sep 5, 2008.

  1. #1
    I have been trying to get .htaccess to work for some permanent redirects. I cannot work out why

    http://www.steinbeck-reeves.co.uk/property/66RCG/floorplan.html

    does not redirect to

    http://www.steinbeck-reeves.co.uk/index.html

    My .htaccess file is as follows (the 404 stuff seems fine)
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    #Error pages 
    ErrorDocument 404 http://www.steinbeck-reeves.co.uk/404.html
    #Permanent redirection
    RewriteBase /
    RewriteRule ^property[.*]$ http://www.steinbeck-reeves.co.uk/index.html [R=301,L]
    RewriteRule ^projects[.*]$ http://www.steinbeck-reeves.co.uk/index.html [R=301,L]
    RewriteRule ^contact\.html$ http://www.steinbeck-reeves.co.uk/Contact.html [R=301,L]
    RewriteRule ^inspirations\.html$ http://www.steinbeck-reeves.co.uk/Inspirations.html [R=301,L]
    RewriteRule ^resources\.html$ http://www.steinbeck-reeves.co.uk/index.html [R=301,L]
    #
    #Hotlink protection
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://steinbeck-reeves.co.uk/.*$ [NC] [OR]
    RewriteCond %{HTTP_REFERER} !^http://www.steinbeck-reeves.co.uk/.*$ [NC] [OR]
    RewriteCond %{HTTP_REFERER} !^http://steinbeck-reeves.com/.*$ [NC] [OR]
    RewriteCond %{HTTP_REFERER} !^http://www.steinbeck-reeves.com/.*$ [NC] [OR]
    RewriteCond %{HTTP_REFERER} !^http://steinbeck-reeves.uk.com/.*$ [NC] [OR]
    RewriteCond %{HTTP_REFERER} !^http://www.steinbeck-reeves.uk.com/.*$ [NC] [OR]
    RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg)$ - [F]
    
    Code (markup):
    Thanks,

    Michael
     
    Michaels-r, Sep 5, 2008 IP
  2. Michaels-r

    Michaels-r Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have done a bit more fiddling with this - always the problem when you are tired. The rules without the wildcards seem to work fine.
    contact.html -> Contact.html
    inspirations.html -> ...
    But if I uncomment the property or the projects lines it fails and locks up the server.
    (I have added lines to specifically redirect property.html and projects.html which work perfectly) Obviously I am getting something wrong with the wildcard part but I cannot understand what it is.... Something to sowith sub-folders?

    I really do need some help here!

    Thanks,
    Michael
     
    Michaels-r, Sep 6, 2008 IP