问题描述
我想我的网站显示为 www.mysite.com ,不是 www.mysite.com /
I want my site to show up as www.mysite.com, not www.mysite.com/
请问Apache的一个域名后添加一个斜线默认情况下,还是浏览器中添加呢?如果我想用一个.htaccess至prevent这一点,将URL重写规则是什么?
Does Apache add a trailing slash after a domain name by default, or does the browser append it? If I want to prevent this using an .htaccess, what would the url rewrite rule be?
推荐答案
如果您要求:
http://myhost.com
请求需要像这样在HTTP:搜索结果
GET / HTTP / 1.0 -
主持人:myhost.com结果
The request needs to look like this in HTTP:
GET / HTTP/1.0
Host: myhost.com
由于历史的原因,一些浏览器没有追加斜杠,否则将其转换为
For historical reasons, some browsers did append the slash because otherwise it translates to
获取LT;没有什么> HTTP / 1.0 -
主持人:myhost.com结果
GET <nothing> HTTP/1.0
Host: myhost.com
这将是一个非法的请求。
Which would be an illegal request.
需要注意的是:
http://myhost.com/page
是合法的,因为它翻译成:
is legal, because it translates to:
GET /页HTTP / 1.0 -
主持人:myhost.com结果
GET /page HTTP/1.0
Host: myhost.com
这篇关于preventing的域名结尾的斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!