问题在卸下倍以上斜线从URL通过的.htaccess [英] Issue In Removing Double Or More Slashes From URL By .htaccess

查看:94
本文介绍了问题在卸下倍以上斜线从URL通过的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的htaccess的RUL从网站的网址删除倍以上斜线:

I am using the following htaccess rul to remove double or more slashes from web urls:

#remove double/more slashes in url
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

这是工作的罚款,发生斜线URI中,如中间,如果使用网址:

This is working fine for slashes occured in the middle of uris, such as, If use url:

http://demo.codesamplez.com/html5//audio

其被重定向到合适的单slahs网址:

Its being redirected to proper single slahs url:

HTTP://demo.$c$csamplez.com/html5/audio

但如果URL包含双斜杠在开始的时候,刚过域名,那么它不工作,例如:

But if the url contains double slashes in the beginning, JUST AFTER the domain name, then there its not working, example:

http://demo.codesamplez.com//html5/audio

它不是被重定向。

its not being redirected.

如何解决上述规则的工作对这种类型的网址呢?谢谢你。

How I can fix the above rule to work for this type of urls as well? Thanks.

推荐答案

给它一个尝试:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/{2,} [NC]
RewriteRule ^(.*) $1 [R=301,L]

有应该重定向到单斜线在域的端部。 和你们的改进:

It should redirect to a single slash at the end of the domain. And an improvement on yours:

RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule . %1/%2 [R=301,L]

这篇关于问题在卸下倍以上斜线从URL通过的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆