htaccess 重定向未按预期工作
我知道我错过了一些简单的东西,但我无法让这个重定向正常工作。我有一个停放域名,我想将其重定向到主域名。我正在使用:
RewriteCond %{HTTP_HOST} ^parked-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/$1 [L,R=301]
问题是parked-domain.com/anypage.html重定向到main-domain.com并忽略了URL的其余部分。我需要 Parked-domain.com/anypage.html 重定向到 main-domain.com/anypage.html
编辑 我确信这是我的浏览器的缓存问题,但在我尝试了第一个建议然后将其改回来后,现在我得到了:
parked-domain.com/anypage.html 重定向到 www.main-domain.com/anypage.html
但
www.parked-domain.com/anypage.html 根本不重定向。
I know I am missing something simple, but I can't get this redirect to work right. I have a parked domain that I want to redirect to the main domain. I am using:
RewriteCond %{HTTP_HOST} ^parked-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.main-domain.com/$1 [L,R=301]
The problem is that parked-domain.com/anypage.html redirects to main-domain.com and leaves off the rest of the URL. I need parked-domain.com/anypage.html to redirect to main-domain.com/anypage.html
EDIT
I am sure this is a cache thing with my browser but after I tried the first suggestion then changed it back, now I get this:
parked-domain.com/anypage.html redirects to www.main-domain.com/anypage.html
but
www.parked-domain.com/anypage.html does not redirect at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
部分问题出在缓存上,导致部分重定向工作正常。我最终使用它来正确转发所有内容:
第一个应该适用于所有情况,但事实并非如此。添加第二个重定向修复了它。
Part of the problem was with the cache, that got part of the redirect working. I ended up using this to get it all forwarding properly:
The first one should have worked for all cases, but it didn't. Adding the second redirect fixed it.
尝试删除 (.*) 周围的 ^ $
Try removing the ^ $ around your (.*)