3

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 !

1 Answer 1

1

You have 3 groups but only two parameters, try with two groups

RewriteRule ^mydir/([0-9]+)/(.*)$ myfile.php?var1=$1&var2=$2 [NC,L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.