我有一个具有这种结构的example.com网站:
public_html/
.htaccess
index.php
project/
.htaccess
public/
index.phppublic_html/.htaccess的内容如下:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]public_html/project/.htaccess的内容如下:
RewriteEngine On
RewriteRule !^public/ /public%{REQUEST_URI} [L]实际效果
当url是public_html/index.php example.com时,我可以看到
当url是public_html/project/public/index.php时,我无法看到example.com/project.错误404
预期结果
当url是public_html/index.php example.com时,我希望能够看到
我想在url是public_html/project/public/index.php的时候看到example.com/project
加成信息
如果我将public_html/project/.htaccess的代码放到根的htaccess文件中,它就能工作。
示例:
public_html/
.htaccess
index.php
project/
index.phppublic_html/.htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteRule !^project/ /project%{REQUEST_URI} [L]如果url是example.com,我可以看到
发布于 2022-08-01 19:34:41
public_html/.htaccess的内容应该是:
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L]public_html/project/.htaccess的内容应该是:
RewriteEngine On
RewriteRule ^$ public/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^public/ public/index.php [L,NC]请确保从新浏览器中测试它,以避免旧缓存。
https://stackoverflow.com/questions/73197182
复制相似问题