简体   繁体   中英

.htaccess rewriting rule with added question mark

Problem is simple, but not understanding of how htaccess works, makes me confused.

Htaccess contains:

RewriteRule ^up/(.*).mp4$ upload/vid.php?id=$1.mp4 [NC]

Simple as that, once i use: mydomain.com/up/movie2.mp4 , it will redirect to: mydomain.com/upload/vid.php?id=movie2.mp4

How can i add to my htaccess file so once i put: mydomain.com/up/movie2.mp4?dl it will redirect to mydomain.com/upload/dl.php?id=movie2.mp4

Any ideas how can i make it works?

You need to use RewriteCond %{QUERY_STRING} to match ?dl :

RewriteEngine On

RewriteCond %{QUERY_STRING} ^dl [NC]
RewriteRule ^up/(.+\.mp4)$ upload/dl.php?id=$1 [NC,L,QSA]

RewriteRule ^up/(.+\.mp4)$ upload/vid.php?id=$1 [NC,L,QSA]

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