1

I have a .htaccess rule that goes like this

RewriteRule ^account/(.*) myaccount.php?p=$1 [NC,L]

This works fine for URLs like https://www.example.com/account/abcd. However, now I want to pass query parameters to this URL, something like https://www.example.com/account/abcd?ab=1&cd=2.

Can't figure out the exact .htaccess rule that can accommodate this. Any pointers?

1 Answer 1

2

Use:

RewriteRule ^account/(.*) myaccount.php?p=$1 [QSA,NC,L]

With QSA:

QSA|qsappend
When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
http://httpd.apache.org/docs/current/rewrite/flags.html

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.