Search code examples
regexapachemod-alias

RedirectMatch RegEx — Need to have an exception


I have this RedirectMatch directive:

RedirectMatch 404 (.old|.csv|.txt|.sql|.ini)$

I now want to exlude robots.txt, but keep sending the 404 for all other .txt. How?

I fiddled with it looking at RedirectMatch 403 -- Need to have an exception for 1 URL in .htaccess but I could not make it work.

Can you help?


Solution

  • You can use negative look-behind

    RedirectMatch 404 (.old|.csv|(?<!robots).txt|.sql|.ini)$