本文介绍了htaccess的重定向所有页面的新域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这重定向规则,我会用它来重定向在 olddomain 所有页面重定向到 newdomain ?
Which redirect rule would I use to redirect all pages under olddomain to be redirected to newdomain?
该网站有一个完全不同的结构,所以我想每一页下的旧域名重定向到新域的索引页
The site has a totally different structure, so I want every page under the old domain to be redirected to the new domain index page.
我想这会做(olddomain根目录下):
I thought this would do (under olddomain base directory):
RewriteEngine On RewriteRule ^(.*)$ newdomain/ [R=301]
但是,如果我浏览到 olddomain/somepage 我重定向到 newdomain/somepage 。我期待一个重定向仅 newdomain 而不在网页后缀。
But if I navigate to olddomain/somepage I get redirected to newdomain/somepage. I am expecting a redirect only to newdomain without the page suffix.
我如何保持的最后一部分了呢?
How do I keep the last part out?
推荐答案可能是这样,没有测试
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^OLDDOMAIN\$ [NC] RewriteRule ^(.*)$ NEWDOMAIN [R=301,L]更多推荐
htaccess的重定向所有页面的新域名
发布评论