[英]Rewrite rule .htaccess with one slash at the end of link
I need one slash to end of all links in my site after rewriting. 重写后,我需要一个斜杠结束站点中所有链接的结尾。 How can I get it?
我怎么才能得到它? I need to remove all extraneous slashes except one from the end of my URLs.
我需要删除所有多余的斜杠,但URL末尾必须有一个。 For example:
例如:
http://www.mydomen.com/test///
should be rewritten to http://www.mydomen.com/test/
http://www.mydomen.com/test///
应该重写为http://www.mydomen.com/test/
I've tried this: 我已经试过了:
RewriteRule ^(.+)//$ /$1 [L,R=301]
But it doesn't work. 但这是行不通的。 What's the correct rewrite rule to do this?
正确的重写规则是什么?
尝试RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
is this working?: 这管用吗?:
RewriteEngine On
RewriteRule ^(.+)/{2,}$ $1/ [L,R=301]
And make sure this is at the beginning of your .htaccess
file. 并确保这是在您的
.htaccess
文件的开头。 the [L]
stands for Last
[L]
代表Last
试试看:
RewriteRule ^(.*)([^/]) /$1 [L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.