在URL中隐藏文件扩展名和php获取变量


Hide file extension and php get variables in URL

我有这样的URL:

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

我需要strip.php?url=到如下url:

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

刚刚尝试:

  1. 修改.htaccess文件:RewriteRule ^news/(.*) news.php?url=$1 [L,QSA]
  2. 将strtok放入news.php:

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

但它不起作用,在根文件夹中,Drupal CMS正在运行,这意味着文件index.php可以处理所有内容。

我的.htaccess文件在这里:http://pastebin.com/xktzt0yc

请帮忙!

如果我理解正确,您的模式和替换是混合的。你试过换个花样换个花样吗?

RewriteRule news.php?url=(.*) ^news/$1 [L,QSA]