2

I have a rule in the .htaccess file that makes a shorter URL:

RewriteRule ^job(.*)$ /include/myfile.incl.php?proj=$1 [NC,L] 

So the final URL looks like:

mydomain.com/jobXXXXXX 

I need to be able to add a token to the URL

mydomain.com/jobXXXXXX?token=123 

How do I modify my rewrite rule to accept this value? Most of the time I won't have token present, but I need the rule overwrite to be flexible to accommodate it, in case I get it is the future.

4
  • 3
    Use the QSA flag ~ wiki.apache.org/httpd/RewriteFlags/QSA Commented Jul 9, 2014 at 2:06
  • @Phil You should post it as answer and then get the question tagged as answerd Commented Jul 9, 2014 at 2:31
  • @Bob0t Meh, I don't like RTFM answers Commented Jul 9, 2014 at 3:00
  • @Phil haha x') you are the funny guy :P Commented Jul 9, 2014 at 7:20

1 Answer 1

3

Try this rule (added QSA(Query String Append) flag for pass the query string):

RewriteRule ^job(.*)$ /include/myfile.incl.php?proj=$1 [NC,QSA,L] 

result (simulated):

Sign up to request clarification or add additional context in comments.

7 Comments

OK, if I just use QSA, without NC, L the error goes away, but I still do not get the token value from $_GET...
Make a var dump of the $_REQUEST superglobal to see where did it go
var_dump($_REQUEST); produces: array(0){ }
@santa try to add "B" flag. i will help solve your problem, soon. (plz wait)
@santa im working this code.. puu.sh/a3dG8/812bff1bdc.png what version of apache is running?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.