redirect old wordpress posts to new wordpress page

New to mod_rewrite? This is a good place to start.

redirect old wordpress posts to new wordpress page

Postby jsherk » Mon Sep 28, 2009 7:52 pm

Hi

I have an old wordpress blog that no longer exists, and I want to redirect all requests to any of those articles to the main page of my new blog.

So far, I have this:
Code: Select all
RewriteRule ^blog-news.*$ http://www.mydomain.com/more/news/ [R=301,NC,L]


The following requests will succesfully be redirected:
www.mydomain.com/blog-news
www.mydomain.com/blog-news/
www.mydomain.com/blog-news/any-text-here

They are succesfully redirected to:
www.mydomain.com/more/news/

The problem is that the following request does NOT get redirected properly:
www.mydomain.com/blog-news/?p=123

It improperly gets redirected to this:
www.mydomain.com/more/news/?p=123

When it should instead go here, like the others:
www.mydomain.com/more/news/

Why does the ?p=123 get passed thru to the redirect?
How do I stop it from doing that?

Thanks
jsherk
 
Posts: 5
Joined: Mon Sep 28, 2009 7:38 pm

Postby richardk » Tue Sep 29, 2009 2:33 pm

An empty query string will remove the original query string. Add a ? after the new path.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^blog-news(/.*)?$ http://www.mydomain.com/more/news/? [NC,R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jsherk » Tue Sep 29, 2009 2:38 pm

Excellent... that did it!

Thank you!
jsherk
 
Posts: 5
Joined: Mon Sep 28, 2009 7:38 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 28 guests

cron