Reputation: 13643
I saw a lot of similar questions, but I couldn't solve this problem with their answers..
I'm trying to do a URL Rewrite by converting
http://example.com/myfile.php?var1=42&var2=aString
to
http://example.com/mydir/42/aString
I tried the following RewriteRule
's (one by one) :
RewriteRule ^mydir/([0-9]+)/(.*)/(.*)$ myfile.php?var1=$1&var2=$2 [NC,L]
RewriteRule ^mydir/([0-9]+)/(.+)/(.+)$ myfile.php?var1=$1&var2=$2 [NC,L]
RewriteRule ^mydir/([0-9]+)/?$/?$ myfile.php?var1=$1&var2=$2 [NC,L]
I couldn't get them work.. What am I doing wrong? and how can I make it work?
Thanks !
Upvotes: 3
Views: 7512
Reputation: 97672
You have 3 groups but only two parameters, try with two groups
RewriteRule ^mydir/([0-9]+)/(.*)$ myfile.php?var1=$1&var2=$2 [NC,L]
Upvotes: 1