无法在查询字符串中获取点

时间:2016-02-26 08:52:28

标签: php .htaccess

这是我要求的网址:

localhost/register... // with dotes at the end

尝试使用$_GET获取URI时:

echo $_GET['uri'];

返回register

我只有2个档案: .htaccess文件:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$  home.php?uri=$1    [L,NC,QSA]

和home.php:

<?php
echo $_GET['uri'];
?>

我如何获得确切的查询字符串?

编辑: 当url是这样的时候它可以工作:

localhost/home.php?uri=register.. // returns register..

但在url是这样的时候不起作用:

localhost/register... // returns register

1 个答案:

答案 0 :(得分:1)

尝试使用此规则替换您的规则,我们从%{REQUEST_URI}中获取值:

RewriteEngine On
RewriteBase /xampp/external/projects/

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/xampp/external/projects/(.*)$
RewriteRule ^ page.php?uri=%1 [L,QSA]
相关问题