[英]yii2 htaccess allow direct access for a file
I'm working on a yii2 advance application project. 我正在研究yii2高级应用程序项目。 I have an .htaccess
file with this content in my project root: 我的项目根目录中有一个带有此内容的.htaccess
文件:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ backend/web/$1 [L]
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
This will hide frontend/web
and backend/web
from url( official yii wiki ). 这将从url( 官方yii wiki )隐藏frontend/web
和backend/web
。
But, now I need to access just test.php
file in my project root directly(without applying MVC structure rules). 但是,现在我需要访问只是 test.php
在我的项目的根直接文件(不应用MVC结构规则)。 In fact, I want to access mydomain.com/test.php
directly. 实际上,我想直接访问mydomain.com/test.php
。 How can I do this? 我怎样才能做到这一点?
Note that I don't want to open direct access for any other files. 请注意, 我不想打开任何其他文件的直接访问权限。
如果您想直接访问特定文件,可以将其放在frontend/web
目录中,就是这样,您定义的规则将适用于frontend/web
的隐藏,您可以使用mydomain.com/test.php
访问它mydomain.com/test.php
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.