Forum Moderators: phranque

Message Too Old, No Replies

Converting from PHPNuke to Wordpress, htaccess redirection.

         

gilgsn

5:16 pm on Dec 15, 2009 (gmt 0)

10+ Year Member



I want to change:

/modules.php?name=News&file=article&sid=3550

To:

/archives/3550

RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]*)
RewriteRule ^modules\.php$ /archives/$1 [R=301,L]

I get this:

/archives/3551?name=News&file=article&sid=3550

What am I doing wrong?

Thanks!

Gil.

By the way, I wrote a Python script to convert PHPNuke MySQL data to Wordpress: <snip>

[edited by: jdMorgan at 7:20 pm (utc) on Dec. 15, 2009]
[edit reason] No URLs, please. See TOS. [/edit]

jdMorgan

7:19 pm on Dec 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to back-reference the sid from the query string matched in the RewriteCond, use "%1" instead of the "$1" (which refers to the first parenthesized match captured in the RewriteRule pattern, as documented in the Apache mod_rewrite docs).

Stick a question mark on the end of the substitution URL to clear the current query string (also as documented).

Also, you should include the protocol and the canonical hostname in the substitution address:


RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]*)
RewriteRule ^modules\.php$ [i]http://www.example.com[/i]/archives/[b]%1?[/b] [R=301,L]

Jim

gilgsn

7:45 pm on Dec 15, 2009 (gmt 0)

10+ Year Member



Thanks Jim, it works! I had tried before with the %1, but forgot the ? at the end..

Gil.