我设置了.htaccess文件,如果应用程序刚刚下载,请重定向到_install文件夹。我遇到的问题是,如果将应用程序上传到根文件夹以外的文件夹,则重定向中断。它尝试转到根文件夹RewriteEngine on#allow installationRewriteCond %{REQUEST_URI} !^/_install#redirect to _install if vendor does not existRewriteCond %{DOCUMENT_ROOT}/vendor !-d RewriteRule ^(.*) /_install [L,redirect=302]#start application if vendor exists#allow installation to continueRewriteCond %{REQUEST_URI} !^/_installRewriteCond %{DOCUMENT_ROOT}/vendor -d RewriteRule ^(.*) public/$1 [L]因此,如果应用程序位于它重定向到的文件夹中,而不是 ./project/_install/project/_install我如何确保无论应用程序位于哪个文件夹,它都会从该文件夹中获取所有内容?
1 回答
慕斯王
TA贡献1864条经验 获得超2个赞
你可以这样使用它:
RewriteEngine on
# Determine the RewriteBase automatically/dynamically in env variable BASE
RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=BASE:%2]
#allow installation
RewriteCond %{REQUEST_URI} !/_install [NC]
#redirect to _install if vendor does not exist
RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}vendor !-d
RewriteRule ^ %{ENV:BASE}_install [L,R=302]
#start application if vendor exists
#allow installation to continue
RewriteCond %{REQUEST_URI} !/_install
RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}vendor -d
RewriteRule ^(.*) public/$1 [L]
- 1 回答
- 0 关注
- 72 浏览
添加回答
举报
0/150
提交
取消