htaccess的重定向所有页面的新域名 [英] .htaccess redirect all pages to new domain
问题描述
这重定向规则,我会用它来重定向在 olddomain.com
所有页面重定向到 newdomain.com
?
Which redirect rule would I use to redirect all pages under olddomain.com
to be redirected to newdomain.com
?
该网站有一个完全不同的结构,所以我想每一页下的旧域名重定向到新域的索引页
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.com根目录下):
I thought this would do (under olddomain.com base directory):
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]
但是,如果我浏览到 olddomain.com/somepage
我重定向到 newdomain.com/somepage
。我期待一个重定向仅 newdomain.com
而不在网页后缀。
But if I navigate to olddomain.com/somepage
I get redirected to newdomain.com/somepage
. I am expecting a redirect only to newdomain.com
without the page suffix.
我如何保持的最后一部分了呢?
How do I keep the last part out?
推荐答案
可能是这样,没有测试
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
这篇关于htaccess的重定向所有页面的新域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!