user1667532
user1667532

Reputation: 1

htaccess redirection to new params

i want an html redirection to a different php and params, the phps are inside a subdirectory , for example, from an /subdir/index.php?thread=23-post=12 /subdir/to showthread.php?topic=23&topic=12. But isn't working this:

RewriteRule ^/test/index\.php?thread=(.*)-post=(.*)$ /test/showthread.php?topic=$1&topic=$2 [R]

Any suggestion?

thanks in advance

Upvotes: 0

Views: 22

Answers (1)

Jon Lin
Jon Lin

Reputation: 143896

You can't match against the query string in a RewriteRule. You need to match against the %{QUERY_STRING} var in a RewriteCond and use the % backreference:

RewriteCond %{QUERY_STRING} ^thread=([^-]+)-post=(.*)$
RewriteRule ^/?test/index\.php$ /test/showthread.php?topic=%1&topic=%2 [L,R]

Note that your rule maps 2 things to the topic query string param.

Upvotes: 1

Related Questions