- 论坛徽章:
- 0
|
为什么访问apahche服务器时,地址后面一定要加“/”
Why does accessing directories only work when I include the trailing "/" (e.g., http://foo.domain.com/~user/) but not when I omit it (e.g., http://foo.domain.com/~user)?
When you access a directory without a trailing "/", Apache needs to send what is called a redirect to the client to tell it to add the trailing slash. If it did not do so, relative URLs would not work properly. When it sends the redirect, it needs to know the name of the server so that it can include it in the redirect. There are two ways for Apache to find this out; either it can guess, or you can tell it. If your DNS is configured correctly, it can normally guess without any problems. If it is not, however, then you need to tell it.
Add a ServerName directive to the config file to tell it what the domain name of the server is.
from apache faq
英文的大意是..当你输入一个网址没有带/的时候,apache需要知道你的服务器名..然后会自动在后面添加一个/给客户端...它有两种方式完成这个过程..一个就是它自动识别...还有一个就是我们在conf文件中手动添加servername.
如果你的dns server配置正确就会没有问题...如果有问题我们可以手动在httpd.conf中的servername段中加入我们的server名.
举个例子:我的apache服务器地址是4lan.ods.org.平时输入地址都是没有问题的.但是我在上面弄个bbs的时候就有问题了...bbs.的地址为4lan.ods.org/bbs
平时我都要在后面加一个/才能正确访问...现在我手动在httpd.conf中加入servername 4lan.ods.org
这样我输入4lan.ods.org/bbs就可以了.....就是这么简单....
btw:我是动态ip...用dhcp的hostname会被自动分配成localhost.localdomain..... |
|