Htaccess 以某种方式自动删除 url 末尾的所有尾部斜杠并只保留一个。
例如http://localhost/api/param1/// http://localhost/api/param1///变成http://localhost/api/param1/ http://localhost/api/param1/
您能告诉我为什么会发生这种情况以及如何消除这种情况吗? (.*) 应该匹配所有内容,对吧?但事实并非如此。就像我说的,如果我去http://localhost/api/param1/// http://localhost/api/param1/// the $_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]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)