jerrygarciuh
jerrygarciuh

Reputation: 21988

htaccess allow access to one PHP file

My initial .htaccess allows access only to non-php files in a directory:

Order deny,allow
Deny from all
<Files ~ ".(xml|css|jpe?g|png|gif|js|pdf)$">
  Allow from all
</Files>

I want to allow access now to one specific php file (relative path from .htaccess foo/bar/baz.php)

Tried adding

<Files foo/bar/baz.php>
  order deny,allow
  Allow from all
</Files>

also tried

<Files ~ "(baz)$">
  order deny,allow
  Allow from all
</Files>

How do I add access for this one file?

Upvotes: 4

Views: 13508

Answers (1)

anubhava
anubhava

Reputation: 784988

Can you try:

Order deny,allow
Deny from all

<Files ~ "\.(xml|css|jpe?g|png|gif|js|pdf)$">
  Allow from all
</Files>

<Files ~ "baz\.php$">
  Allow from all
</Files>

Upvotes: 8

Related Questions