2014-07-21 118 views
1

我的问题是,当我输入http://example.com/admin/时效果很好,$_GET['decode']包含正确的信息,我可以使用它。但是当我输入http://example.com/admin(没有斜杠)时,我的URL重定向到http://example.com/admin/?decode=admin,并且一切都搞乱了。有人可以帮助我吗?URL漏洞末尾的斜线.htaccess

这里是我的.htaccess

RewriteEngine on 
Options +FollowSymlinks 

<FilesMatch "(config.php|defines.php|functions.php)"> 
    Order Allow,Deny 
    Deny from all 
</FilesMatch> 

Header set X-UA-Compatible "IE=Edge,chrome=1" 

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L] 

RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 

RewriteRule ^([^\.]+)$ ./index.php?decode=$1 [L,QSA] 

php_value date.timezone "Europe/Bratislava" 

回答

2

这是因为mod_dir是增加你的最后一条规则后的目录URI(/admin)尾部斜杠被mod_rewrite运行。

试试这个代码:

DirectorySlash Off 
RewriteEngine on 
Options +FollowSymlinks 

<FilesMatch "(config.php|defines.php|functions.php)"> 
    Order Allow,Deny 
    Deny from all 
</FilesMatch> 

Header set X-UA-Compatible "IE=Edge,chrome=1" 

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
RewriteRule^http://%1%{REQUEST_URI} [R=301,NE,L] 

## Adding a trailing slash 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{THE_REQUEST} \s/+(.*?)[^/][?\s] 
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/?$ ./index.php?decode=$1 [L,QSA] 

php_value date.timezone "Europe/Bratislava" 
+0

抱歉,但这是不工作的权利 – debute

+0

现在就来试试。我在顶部添加了“DirectorySlash Off”。 – anubhava

+0

它仍然将我重定向到'/ admin /?decode = admin' – debute