Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

php - friendly url don't recognize variable

I use in my .htaccess

RewriteRule ^profiles/([A-Za-z0-9-]+)/$ /profile.php?city=$1 [NC]

Works normally when accessing the url: https://site.com.br/profiles/londres

But in the page, after insert an variable get, the php recognizes only the variable configured in htaccess, example when accessing the url:

https://site.com.br/profiles/londres?s=username

print_r($_GET); return Array ( [city] => londres)

that is, it does not return the variable s in GET


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use QSA flag in your rule to get query string as well.

RewriteRule ^profiles/([A-Za-z0-9-]+)/$ /profile.php?city=$1 [NC,QSA]

Reference:

https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_qsa


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...