DiPaSerious
DiPaSerious

Reputation: 3

Allow access to "Deny from all" directory

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.

Upvotes: 0

Views: 144

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

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).*)$

Upvotes: 0

Related Questions