简体   繁体   English

.htaccess 301重定向整个WordPress网站(根域除外)

[英].htaccess 301 redirect WHOLE WordPress site EXCEPT root domain

I have been searching around and I couldn't find the following. 我一直在搜索,但找不到以下内容。 I was wondering if it is possible to redirect my whole WordPress blog to a new domain except for the root or homepage itself. 我想知道是否可以将我的整个WordPress博客重定向到一个新域,但根目录或首页本身除外。 Any push in the right direction would be great. 朝正确方向的任何推动都将是巨大的。 I hope I'm not asking a silly question here! 我希望我在这里不要问一个愚蠢的问题!

Thanks in advance for anyone who has the time to look at my question. 预先感谢任何有时间查看我的问题的人。

Yes you can, try this code : 是的,您可以尝试以下代码:

RewriteEngine on

RewriteRule ^(index.php)?$ - [L]

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(.+)$ http://www.newdomain.com/$1 [R=301,QSA,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM