我正在尝试使用htaccess将子目录作为其他域的根目录。我目前有:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?thedrive.co$
RewriteCond %{REQUEST_URI} !^/test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test/$1
RewriteCond %{HTTP_HOST} ^(www.)?thedrive.co$
RewriteRule ^(/)?$ test/index.php [L]
它很好用并隐藏了URL中的'test'目录。但是,当请求子目录中的文件时,它会显示“test”目录。例如,代替thedrive.co/somefolder,它显示了drive./test/somefolder。
如何让它不显示?
答案 0 :(得分:1)
在RewriteEngine on
行下方的顶部插入301规则:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?radioreformation\.co$ [NC]
RewriteCond %{THE_REQUEST} \s/+radioreformation.com/(\S*) [NC]
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www.)?radioreformation.co$
RewriteCond %{REQUEST_URI} !^/radioreformation.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /radioreformation.com/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?radioreformation.co$
RewriteRule ^(/)?$ radioreformation.com/index.php [L]
这会将thedrive.co/test/somefolder
重定向到thedrive.co/somefolder