繁体   English   中英

.htaccess:将除某些页面以外的所有页面重定向到新域

[英].htaccess: Redirect all pages to a new domain, except certain pages

我有一个安装有Wordpress的博客网站。 博客作者现在将开始为当地报纸发帖。 基本上,我想要这样:

  • 所有文章/页面都应重定向到报纸网站上的新博客主页。
  • 一些文章不应重定向到主页,而应重定向到报纸网站上的新URL。

到目前为止,我有这个:

RewriteEngine On

# Redirect specific articles
RewriteCond %{REQUEST_URI} article-slug-goes-here
RewriteRule .* http://www.newspaper.com/theblog/588433/article-slug-goes-here.html [R=301,L]


# Redirect all other stuff to the home
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*)$ http://www.newspaper.com/theblog/ [R=301,L]

第一部分有效,而其他部分无效。 我应该能够将其他文章添加到重定向列表中,以便将它们重定向到其相应的新URL。

您可以具有如下规则:

RewriteEngine On

# Redirect specific articles
RewriteRule ^(article1|article2|article3) http://www.newspaper.com/theblog/588433/article-slug-goes-here.html [R=301,L]

# Redirect all other stuff to the home
RewriteRule ^ http://www.newspaper.com/theblog/ [R=301,L]

暂无
暂无

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

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