Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想完全删除 URL 末尾的所有斜杠或反斜杠。
http://www.mp7.org/?site=69.com\\\\\\\\\\\\\
通过 .htaccess 或 PHP。
以下 .htaccess 规则不起作用:
RewriteRule ^(.*)[/\]+$ $1 [L,R=301]
#### mod_rewrite in use Options +FollowSymlinks RewriteEngine On
请提供替代解决方案。
您可以执行以下操作:
$string = substr($string, 0, strpos($string, "\\"));
如果没有 \ 会更早出现
编辑: 要测试的完整代码:
<?php $string = "http://www.mp7.org/?site=69.com\\\\\\\\\\\\\\\\\\\\\\\\\\"; $string = substr($string, 0, strpos($string, "\\")); echo($string); ?>