Nahuel
Nahuel

Reputation: 3585

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

I have a blog website with a Wordpress instalation. The blog author will now start posting for the local newspaper. Basically, I want this:

So far I have this:

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]

The first part works, but no the other part. I should be able to add other articles to the redirect list so that they are redirected to their corresponding new URL.

Upvotes: 2

Views: 2361

Answers (1)

anubhava
anubhava

Reputation: 786339

You can have your rules like this:

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]

Upvotes: 3

Related Questions