简体   繁体   中英

Remove query string from PHP URL using .htaccess

My url is : https://domain.com/chapter-detail.php?board=12&class=145&subject=maths

Now, I want to remove query string from the url and I want to get resultant url as : https://domain.com/chapter-detail.php

You can use the following rule to remove query strings fromthe uri /chapter-detail.php

RewriteEngine on
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^chapter-detail.php$ /chapter-detail.php? [L,R]

你可以用这个

$url=strtok($_SERVER["REQUEST_URI"],'?');

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