htaccess regex in modrewrite help

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?
Who is Participating?
Terry WoodsConnect With a Mentor IT GuruCommented:
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:
the former seems to correspond better with your description
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.