Search code examples
regexapachelocationmatch

LocationMatch rules with Apache


I need to fix (with or without regex) so you can access "/admin.php?+" but not "/SUBSITE/admin.php?+" on a site. Anyone has a good idea of how to fix that?


Solution

  • Here is a regex which might fit your need (your original question was a bit vague):

    ^(?!www\.mysite\.com\/.*\/admin\.php).*$
    

    I have tested this regex and it blocks "www.mysite.com/*/admin.php", but it allows the following:

    www.mysite.com/*/guestbook.php
    www.mysite.com/*.php
    

    If you want additional restrictions in the regex, then let me know and I can refine this answer.

    Regex101