Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

htaccess Expertise please?

  • 10-11-2017 11:36AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 6,684 ✭✭✭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