简体   繁体   中英

Hide file extension and php get variables in URL

I have URL like this :

http://domain.net/news.php?url=/abcd.html

I need strip .php?url= to URL like this:

http://domain.net/news/abcd.html

Just tried :

  1. Modify .htaccess file : RewriteRule ^news/(.*) news.php?url=$1 [L,QSA]
  2. Put strtok in news.php :

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

But it not work, in root folder, Drupal CMS running, that mean file index.php handle everything.

My .htaccess file here : http://pastebin.com/xktzt0yc

Please help!

If I understood correctly, your pattern and substitute is mixed. Have you tried to switch the pattern and substitute?

RewriteRule news.php?url=(.*) ^news/$1 [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