htaccess允许访问一个PHP文件

时间:2023-02-08 07:17:15

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

我的初始.htaccess只允许访问目录中的非php文件:

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)

我想允许访问一个特定的php文件(相对路径来自.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?

如何为这个文件添加访问权限?

1 个解决方案

#1


8  

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>

#1


8  

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>