当末尾不存在反斜杠时,Mod 重写会不断追加 GET 字符串

问题描述 投票:0回答:1
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?route=$1

使用该重写规则,如果我输入任何不以反斜杠结尾的链接,则会在末尾附加

GET
字符串。

示例:

localhost/forum/ 显示为 localhost/forum/

localhost/forum 显示为 localhost/forum/?route=Forum

php .htaccess mod-rewrite
1个回答
0
投票

添加一行

RewriteCond %{REQUEST_FILENAME} !-d

因此当指向现有目录时它不会执行任何操作

© www.soinside.com 2019 - 2024. All rights reserved.