如何避免以后的网址域名的多个斜线使用htaccess的? [英] How to avoid multiple slashes after domain name in url using htaccess?

查看:148
本文介绍了如何避免以后的网址域名的多个斜线使用htaccess的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个链接 http://mysite.com/myname 足见其个人资料页面。但如果我使用多个

I have a link http://mysite.com/myname which shows the profile page.. But if i use multiple

斜线状 http://mysite.com///myname ,这也说明页面。

slashes like http://mysite.com///myname , it also shows the page..

我的htaccess code是:

My htaccess code is :

RewriteCond %{REQUEST_URI} ^/(\w+)/?$ [NC]

RewriteRule ^ profile.php?username=%1 [L,QSA]

如何避免这个问题?

How to avoid this problem?

有人能帮助我吗?

推荐答案

不知道为什么你真的想阻止多个斜线但这里是一个办法做到这一点:

Not sure why do you really want to block multiple slashes but here is a way to do that:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/{2,} [NC]
RewriteRule ^ - [L,F]

这会给Forbidden错误是一个URI有多个斜线在启动类似 /// MYNAME 将生成:

This will give Forbidden error is a URI has multiple slashes at start like ///myname will generate:

禁止

您没有权限访问/ MYNAME在此服务器上。

You don't have permission to access /myname on this server.

这篇关于如何避免以后的网址域名的多个斜线使用htaccess的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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