我的服务器上有多个站点和域
我不知道我做错了什么,但当我切换我的网站目录时,地址路径显示为主目录路径。
/.htaccess
RewriteEngine On
RewriteBase /
Options -Indexes
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule !^example_home_dir/ /example_home_dir%{REQUEST_URI} [L,NC]
当我在主页上时,一切都很好(example.com正在显示example_home_dir的内容(
当我用子目录手动输入域时,一切都认为工作正常(example.com/subdir显示subdir内容(
当我点击锚并重定向到"example.com/subdir"时,服务器会将我重定向到"sample.com/example_main_dir/subdir"并显示subdir内容。
我尝试了很多解决方案,但都没有成功
出于好奇,我会说重定向在我的symfony项目中运行良好
我不知道该怎么办:(非常感谢你的帮助。
您可以使用重定向规则从URL:中删除example_home_dir
DirectorySlash Off
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} s/+example_home_dir/(S*) [NC]
RewriteRule ^ /%1 [L,NE,R=301]
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule !^example_home_dir/ example_home_dir%{REQUEST_URI} [L,NC]
当你有一个指向目录的URL时,还要确保你总是有一个尾随斜杠。因此使用example.com/subdir/
而不是example.com/subdir
。
请确保使用新浏览器来测试此更改。