Protecting integrity of links when changing blog format

Discuss practical ways rearrange URLs using mod_rewrite.

Protecting integrity of links when changing blog format

Postby slobjones » Sun Nov 23, 2008 7:34 pm

I'm migrating my blog to WordPress and want to maintain the integrity of my links.

The old blog follows this format:
Code: Select all
http://www.mysite/?entryid=207

WordPress follows this format:
Code: Select all
http://www.mysite.com/?p=207

I've gone into the WordPress database and re-numbered each entry to match the old blog.

With that done, is there a redirect that will protect my links when I make the switch?

After that, I'll activate the WordPress "Pretty Permalinks" to create friendly urls. I'm presuming this will cause no additional problems.

Thanks.
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm

Postby richardk » Mon Nov 24, 2008 1:06 pm

So you want /?entryid=207 to redirect to /?p=207 (with the address bar changing)?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?entryid=([0-9]+)(&.*)?$ [NC]
RewriteRule ^$ /?p=%2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby slobjones » Wed Dec 03, 2008 5:25 pm

Thank you, richardk. That's just what I needed.
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm

Postby slobjones » Fri Dec 05, 2008 9:21 pm

I'm still having trouble with a few redirects from the old site.

There's probably little chance of finding some formula that will redirect the many deep links involving categories and pages.

But I would like to redirect the following links, as they all pointed to menu items in my old blog format.

For some reason, none of these redirects are working:
Code: Select all
Redirect 301 /?categoryid=11&theme=roundup http://www.mysite.com/?cat=40

Redirect 301 /?categoryid=16&theme=interviews http://www.mysite.com/?cat=103

Redirect 301 /?&theme=music http://www.mysite.com/?page_id=1928

Redirect 301 /?&theme=about http://www.mysite.com/?page_id=1920

Redirect 301 /?&theme=comments http://www.mysite.com/?page_id=1924

Any suggestions?

Thanks.
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm

Postby richardk » Sat Dec 06, 2008 8:39 am

For /?match=old&quesrystring=variables to /?new=quesystring&variables=1
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?match=old(&.*)?$ [NC]
RewriteCond %{QUERY_STRING} ^(.*&)?quesrystring=variables(&.*)?$ [NC]
RewriteRule ^$ /?new=quesystring&variables=1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby slobjones » Sat Dec 06, 2008 2:45 pm

I'm having a little trouble implementing this Rewrite. Could you provide an example using one of the addresses?

For example, to redirect /?categoryid=11&theme=roundup to http://www.mysite.com/?cat=40, what would the formula be?

Thanks.
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm

Postby richardk » Sat Dec 06, 2008 4:42 pm

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?categoryid=11(&.*)?$ [NC]
RewriteCond %{QUERY_STRING} ^(.*&)?theme=roundup(&.*)?$ [NC]
RewriteRule ^$ /?cat=40 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby slobjones » Tue Dec 09, 2008 1:09 pm

Thank you!
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 20 guests

cron