Forums

301 rewrite in .htaccess not working, dynamic -> dynamic (5 posts)

  1. Bike
    Member
    Posted 1 year ago #

    Hi WP team,

    I have recently converted a PixelPost-based photoblog to WP3.0, to take advantage of the WP functionalities.

    However, I cannot seem to create a seemingly easy 301 rewrite to divert all old traffic, not sure if I made mistakes of that the internal rewrite rules of WP block this?

    I searched, but none of the similar threads on the forum have ever been answered.
    How would I rewrite from :

    domain.com/?showimage=xx
    to
    domain.com/?p=xx

    the xx is the variable page ID/number which is the same for both the old as well as the new system.

    Any help is much appreciated!
    Many thanks, Bike

  2. The problem being its not a wordpress question :)

    This URL should help you.

    http://www.chilipepperdesign.com/2009/02/01/htaccess-query-string-301s

  3. Bike
    Member
    Posted 1 year ago #

    Thanks Ipstenu; as long as WP needs .htaccess, then I think this is a WP question :)
    Besides, several people have tried to convert from PixelPost (or other CMS) to Wp, but are worried about whether their old pages 'will work', so I think this is definitely WP-worthy.

    I tried several options, but none worked. Anybody knows what is wrong?

    RewriteRule ^/\?showimage=([0-9]+)/?$ /\?p=$1 [R]
    RewriteRule ^showimage /p [R]

    RewriteCond %{QUERY_STRING} showimage=(.*)
    RewriteRule ^showimage(.*) /?p=%1 [R]

    Thanks, Bike

  4. I would try...

    RewriteRule ^/\?showimage=(.*) http://domain.com/\?p=$1 [R]

    Maybe. Juggling the ? Is a pain.

    Also, why I say it's not a wordpress question is that WP works fine without this code. This is generic web admin stuff, not wordpress specific.

  5. Taking a second look at what I have on my servers...

    RewriteCond %{QUERY_STRING} ^showimage=([0-9]*)$
    RewriteRule ^(.*)$ http://mydomain.site/?p=%1 [R=301,L]

    The catch is telling the server that it's looking for a query string, which is NOT the same as escaping the ? character.

    This is all .htaccess mastery, though :)

Topic Closed

This topic has been closed to new replies.

About this Topic