我知道如何使用PHP,如何将多个从URL替换为仅一个:

http://example.com/uri1////////uri2/uri4

替换为:

http://example.com/uri1/uri2/uri4

等。如何使用HTACCESS?

有帮助吗?

解决方案

将此代码放在您的 DOCUMENT_ROOT/.htaccess 文件:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s[^?]*//
RewriteRule ^.*$ /$0 [R=301,L,NE]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top