Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 289
jerrygarciuh Avatar asked Feb 15 '23 04:02

jerrygarciuh


1 Answers

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>
like image 123
anubhava Avatar answered Feb 28 '23 20:02

anubhava