Forum Moderators: phranque
I am trying to redirect traffic from an old wordpress blog to a new EE blog. Ive gotten all of the posts and categories redirecting, but I am having trouble with the tag links.
I am trying to accomplish all of the following redirects with one mod_rewrite:
oldwordpressite.com/blog/index.php?tag=keyword --> newsite.com/blog/tags/tag/keywordoldwordpressite.com/blog/index.php?tag=two-keywords --> newsite.com/blog/tags/tag/two+keywords
oldwordpressite.com/blog/index.php?tag=long-tail-keyword --> newsite.com/blog/tags/tag/long+tail+keyword
The problem i am running into is the keywords are separated by dashes in wordpress and they are separated by plus signs in EE. Whats the best way to do this?
This is what i have so far, but it doest replace the - with a +
RewriteRule ^blog/index.php?tag=([A-Za-z0-9-]+)$ http://www.example.com/index.php/blog/tags/tag/$1 [R=301,L]
[edited by: jdMorgan at 12:16 am (utc) on Jan. 26, 2008]
[edit reason] example.com [/edit]
# Nine keywords
RewriteCond %{QUERY_STRING} ^tag=([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)$
RewriteRule ^blog/index\.php$ http://www.example.com/index.php/blog/tags/tag/%1+%2+%3+%4+%5+%6+%7+%8+%9? [R=301,L]
#
# Eight keywords
RewriteCond %{QUERY_STRING} ^tag=([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)-([^\-]+)$
RewriteRule ^blog/index\.php$ http://www.example.com/index.php/blog/tags/tag/%1+%2+%3+%4+%5+%6+%7+%8? [R=301,L]
#
... Rules for seven through three keywords
#
# Two keywords
RewriteCond %{QUERY_STRING} ^tag=([^\-]+)-([^\-]+)$
RewriteRule ^blog/index\.php$ http://www.example.com/index.php/blog/tags/tag/%1+%2? [R=301,L]
# One keyword
RewriteCond %{QUERY_STRING} ^tag=([^\-]+)$
RewriteRule ^blog/index\.php$ http://www.example.com/index.php/blog/tags/tag/%1? [R=301,L]
If you can meet your requirements using nine rules like the example rules above, then you'll likely be happier doing it that way. If not, things are going to get ugly -- and/or very slow.
Jim