【发布时间】:2016-11-11 10:59:06
【问题描述】:
我有一个域名foo.tech。
我想改用新域footech.io。
重定向还必须确保所有 URL 都能正常工作。
例如foo.tech/bar 转到footech.io/bar
这是我的.htaccess 文件:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo.tech [NC]
RewriteRule ^(.*) http://footech.io/$1 [R=301,L]
出于某种原因,它决定在我的域末尾添加/html。
所以现在如果我访问foo.tech,它将重定向到footech.io/html
如果我访问foo.tech/bar,它将重定向到footech.io/html/bar
请帮忙。
更新:
我认为/html 来自$1
我尝试将重写规则设置如下:
RewriteRule ^(.*) http://footech.io/$1/$1 [R=301,L]
转到foo.tech 会导致footech.io/html//html/
转到foo.tech/bar 导致footech.io/html/bar/html/bar
最终更新: 我现在使用它使它工作:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo.tech [NC]
RewriteRule ^html/(.*) http://footech.io/$1 [R=301,L]
【问题讨论】:
-
我确实清除了浏览器缓存,不知道你说的是哪个规则
标签: apache .htaccess mod-rewrite url-rewriting