簡體   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