【发布时间】:2013-04-21 15:08:11
【问题描述】:
我想完全删除 URL 末尾的所有斜杠或反斜杠。
http://www.mp7.org/?site=69.com\\\\\\\\\\\\\
通过 .htaccess 或 PHP。
以下 .htaccess 规则不起作用:
RewriteRule ^(.*)[/\]+$ $1 [L,R=301]
#### mod_rewrite in use
Options +FollowSymlinks
RewriteEngine On
请提供替代解决方案。
【问题讨论】:
-
这个网址是怎么生成的?由您还是外部?
-
这是一个测试工具。所有网址都是在外部生成的。
-
它不起作用,因为斜杠是查询字符串的一部分。 "When the requested URI contains a query string, and the target URI does not, the default behavior of RewriteRule is to copy that query string to the target URI"。请参阅wiki.apache.org/httpd/RewriteQueryString 了解如何使用 mod_rewrite 修改查询字符串。