http:// localhost不起作用,http://127.0.0.1

Iam和Apache一起运行Zend,看到一个奇怪的行为….

如果我在我的浏览器urlinputhttp://127.0.0.1 ,它工作正常,但input后: http:// localhost ,我会得到一个文件下载窗口,说文件types为:application / x-httpd-php

在我的httpd.conf文件中,我有以下VirtualHost *:80定义:

ServerName localhost DocumentRoot E:\zend\Apache2\htdocs\my_project\public Directory E:\zend\Apache2\htdocs\my_project\public 

也许一些configuration问题…任何人都可以引导我..

从httpd.conf文件中:

NOTE: Where filenames are specified, you must use forward slashes instead of backslashes (eg, "c:/apache" instead of "c:\apache"). If a drive letter is omitted, the drive on which Apache.exe is located will be used by default. It is recommended that you always supply an explicit drive letter in absolute paths to avoid confusion.

所以改变

DocumentRoot E:\zend\Apache2\htdocs\my_project\public

DocumentRoot "e:/zend/Apache2/htdocs/my_project/public"

Directory E:\zend\Apache2\htdocs\my_project\public是configuration文件中允许和/或禁用该目录中的服务和function的部分,所以它必须如下所示:

<Directory "e:/zend/Apache2/htdocs/my_project/public"> some options </Directory>

如果你在这里发布httpd.conf,或者在某处上传并发布一个指向那个文件的链接

检查您的主机文件,通常在像这样的地方:

C:\windows\system32\drivers\etc

确保有这样一个localhost的条目:

127.0.0.1 localhost

坦率地说,我不能立即明白为什么没有这样一个条目会产生你所报告的结果 – 一个typesapplication/x-httpd-php – 但是当某些东西不能工作的时候,总是最好把所有的东西都打上T的。 😉