简体   繁体   中英

.htaccess with question mark redirection

I want to use .htaccess to rewrite url to my webite:

if url is https://test.example.com/var1?m=var2 , correct redirection url will be: https://test.example.com/getid.php?first=var1&second=var2

an alternative could be:

https://test.example.com/getid.php?total=var1?m=var2

so, after i will do the split..

Where you're probably being tripped up is that the pattern in RewriteRule only matches the path part, not the query string -- you need to use RewriteCond for that

RewriteCond %{QUERY_STRING} m=(.*)
RewriteRule ^(.*)$ getid.php?first=$1&second=%1 [L]

(the above assumes that m is the only query string parameter and will not match if m is not present)

You need a .htaccess on you server webroot path with this in in it:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ getid.php?total=$1 [L,QSA]

Basiclly. Thing you should read into the topic: http://www.askapache.com/htaccess/modrewrite-tips-tricks.html

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