htaccess会以某种方式自动将所有结尾的斜杠移到url的末尾,并仅保留一个。
例如,http:// localhost / api / param1 ///变为http:// localhost / api / param1 /
您能告诉我为什么会发生这种情况以及如何消除这种情况吗?(。*)应该匹配所有内容吗?但事实并非如此。就像我说的,如果我去的http://本地主机/ API /参数1 ///的$_GET['url']
应该是param1///
,但它是param1/
。
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Apache自动将多个斜杠剥离为单个斜杠RewriteRule
模式。
如果要捕获多个斜杠,请RewriteCond
改用:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/(.*)$
RewriteRule ^ index.php?url=%1 [QSA,L]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句