简体   繁体   中英

Mod rewrite with parameters

In fact, I am working on a small PHP script and I want to redirect this :

http://localhost/app-[NUMBERS].html?code=[LETTERS AND NUMBERS]

to this:

http://localhost/app.php?id=[NUMBERS]&code=[LETTERS AND NUMBERS]
RewriteRule ^app-([0-9]+)\.html /app.php?id=$1 [L,QSA]

This captures the numeric portion of the request, and converts it to the id query string parameter. The QSA flag deals with any existing parameters, and passes them through untouched.

eg

http://scratch.bagheera/app-12345.html?code=ABC123

->

http://localhost/app.php?id=12345&code=ABC123

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM