Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional second query in rewrite rule

Tags:

php

.htaccess

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

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

to make the final URL looks like:

mydomain.com/jobXXXXXX

Is it possible to accommodate second query is a user changes my URL like this?

mydomain.com/jobXXXXXX?token=123

I need to be able to pick-up that token value too then.

Perhaps there's a way to add a conditional $2 somehow? I've tried QSA flag but it did not work for me. Perhaps my Apache version is too old... 2.2.3(CentOS)

Whichever solution I could use, another rewrite rule or perhaps in combination with PHP. I'm stuck.


UPDATE

NM... I think the problem is in my PHP, not .htaccess

like image 986
santa Avatar asked Feb 03 '26 13:02

santa


1 Answers

Are you talking about QSA flag?

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

The QSA flag should work. I'm using it 5 years now.

like image 169
machineaddict Avatar answered Feb 05 '26 04:02

machineaddict



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!