htaccess regex in modrewrite help

Posted on 2012-08-21
Last Modified: 2012-09-11
Ok so, i have a folder, which contains php scripts.
I wana make it so if its a script i dont want them to see, i easily throw them to a 404 page.
However, for this one folder, there is one subfolder i still need to give them access to. Now im kinda new to regex but i gave it a go:




The idea is, every .php file they try to access will redirect them to the 404, apart from a folder containing the text ajax.

Does anyone know how i can get this regex to work?
Question by:Headchopperz
    LVL 84

    Expert Comment

    the former seems to correspond better with your description
    LVL 34

    Accepted Solution

    Your 2nd attempt isn't what you want, as it's trying to match the exact file:

    The 1st attempt looks good to me though. You may not need to capture the .* part if you're displaying the 404 page, but it should work either way:

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    regex101 site usage 5 275
    Javascript regular expression to accept only Numbers 3 45
    Regular Expression for URL 10 69
    Regex Replacement 9 46
    Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
    As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now