0
votes

What I want to happen is:

  1. Restrict user to access folder and files inside it (something like .htaccess deny from all)
  2. Allow some URL to access files inside this restricted folder.

Scenario:

  1. User access "localhost/php" and "localhost/php/adduser.php" should be denied.
  2. User access "localhost/api/adduser" will display response from "localhost/php/adduser.php"

As far as I know, mod_rewrite can help me with this, but I'm not sure how could this be done.

1
you could also always include the script from inside the function you're using. EG: include 'adduser.php'; and it would include the output from the filesystem while preventing direct access via URL - Zachary Craig

1 Answers

0
votes

To deny access to an entire folder, you can use :

RedirectMatch 403 ^/folder.*$

To allow access to a particular file inside a restricted folder , you could use :

RedirectMatch 403 ^/folder/?((?!this_file).*)$