Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

htaccess Expertise please?

Options
  • 10-11-2017 12:36pm
    #1
    Registered Users Posts: 874 ✭✭✭


    I'm trying to deal with a whole heap of old incoming links on a site I've rebuilt. All of the legacy urls use underscores and the new site uses hyphens. So a htaccess rule to redirect seemed like a good option.

    Problem is it's mucking up some legacy images with underscores in the file names. How do I exclude certain directories from the rewrite?

    Currently using the rule like this:

    #1 Redirect rule to convert _ to -
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)_+[_-]*(.+?)\sHTTP [NC]
    RewriteRule ^ /%1-%2 [L,NE,R=302]

    Thanks.


Comments

  • Registered Users Posts: 6,494 ✭✭✭daymobrew


    I don't know the answer but maybe a check whether the file exists might help.

    In the WordPress default .htaccess code it has:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    I believe that these check whether the request is for an existing file or directory.
    Maybe put these before your lines and see what happens.


Advertisement