简体   繁体   English

重定向除root以外的所有页面

[英]redirect all pages except root

I'm trying to separate out a WordPress site that has 4 specific blog sections built with custom post types to their own individual sites. 我试图将一个WordPress网站分离出来,该网站有4个特定的博客部分,这些博客部分使用自定义帖子类型构建到自己的个人网站。

I have urls that look like: 我的网址看起来像:

example.com/site1/postname example.com/site2/postname etc example.com/site1/postname example.com/site2/postname等

What I need to do is redirect all the posts under each site out to the new site while leaving the root page where it is. 我需要做的是将每个站点下的所有帖子重定向到新站点,同时将根页面保留在原位置。

So example.com/site1/postname becomes example2.com/postname 因此example.com/site1/postname变为example2.com/postname

but example.com/site1/ needs to stay as example.com/site1/ 但是example.com/site1/需要保留为example.com/site1/

And the same for the other 3 sites. 与其他3个网站相同。 Hope that makes sense. 希望有道理。

I have this and it works great at redirecting the posts to the new site but it also redirects the root base as well and can't work out what to change to fix that. 我有这个功能,它可以很好地将帖子重定向到新站点,但是它也可以重定向根目录,因此无法解决要解决的问题。

RewriteEngine on
RewriteRule ^site1/(.*)$ http://www.example2.com/$1 [L,R=301]

To redirect everything except root of all 4 sites use: 要重定向除所有4个站点的root以外的所有内容,请使用:

RewriteEngine on

RewriteRule ^(site1|site2|site3|site4)/(.+)$ http://$1.com/$2 [L,NC,NE,R=301]

.+ after these sites will make sure to not to match root of these folders. 这些站点之后的.+将确保不匹配这些文件夹的根目录。

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

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