简体   繁体   中英

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM