0

I'm currently trying to add a second get variable to an existing htaccess rule. I have little experience with the htaccess but using what expressions I know, I think it's missing one element to ensure the second variable is outputted correctly.

The domain (as the user sees it);

http://domain.com/london-area-info/?src=go

The rule i'm trying to apply;

RewriteRule ^(.*)-area-info/(.*)$ regioncc.php?region=$1&src=$2

The resulting output URL;

http://domain.com/regioncc.php?region=london&src=

I appreciate I'm probably overlooking something but looking around I haven't found an explanation has to how to make sure the ?src=go is shown after the rewrite rule rather than in another directory like /xxx-area-info/src/ for example.

EDIT

I have also tried the following rule but wasn't sure if I was escaping correctly

RewriteRule ^(.*)-area-info/(\?src=?.*)?$ regioncc.php?region=$1&src=$2

1 Answer 1

1

I believe this is what you want:

RewriteRule ^(.*)-area-info regioncc.php?region=$1&%{QUERY_STRING}
Sign up to request clarification or add additional context in comments.

2 Comments

This has done the trick! And yet I never even knew about {QUERY_STRING}, I'm going to go read up on it now. Thank you very much
Since you are sending in values after ? those get processed separately and stored in {QUERY_STRING} so you just need to add them back in to the resulting url.

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.