mod rewrite problem

Status
Not open for further replies.

Lucidity

New member
Jul 30, 2007
419
9
0
I'm trying to accomplish a routine dynamic to static redirection, but on this particular site it is confounding me.

I want to convert index.php?var=5 to /var-5

This is my what I have in .htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^var\=([0-9]+)$
RewriteRule ^index\.php$ /var-%1 [R=301]

What I get is this: /var-5?var=5

No matter what I try, "?var=5" is appended to the end of the URL. What am I doing wrong?
 


try
RewriteRule ^var-([0-9]+)$ index.php?var=$1


You want to rewrite from var-5 to index.php?var=5 not the other way right?
 
You're doing an internal redirect, add a ? to the end to remove the query string

RewriteRule ^index\.php$ /var-%1? [R=301]
 
  • Like
Reactions: Lucidity
Status
Not open for further replies.