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.mydomen.com/test///应该改写为http://www.mydomen.com/test/
http://www.mydomen.com/test///
http://www.mydomen.com/test/
我试过这个:
RewriteRule ^(.+)//$ /$1 [L,R=301]
但它不起作用。这样做的正确重写规则是什么?
尝试RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
试试这个:
RewriteRule ^(.*)([^/]) /$1 [L,R=301]
这管用吗?:
RewriteEngine On RewriteRule ^(.+)/{2,}$ $1/ [L,R=301]
并确保它位于.htaccess文件的开头。[L]代表_Last
.htaccess
[L]
Last