php 在此服务器上找不到请求的 URL /。阿帕奇

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20696603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:25:52  来源:igfitidea点击:

The requested URL / was not found on this server. Apache

phpwindowsapacheurlhttp-status-code-404

提问by user3121483

I've installed Apache 2.2 server and PHP 5.3 on Windows XP SP3. After the initial install, Apache loaded the test page, i.e.,

我已经在 Windows XP SP3 上安装了 Apache 2.2 服务器和 PHP 5.3。初始安装后,Apache 加载了测试页面,即,

http:/localhost(C:/Program Files/Apache2.2/htdocs/index.html) showed "It works!".

http:/localhost(C:/Program Files/Apache2.2/htdocs/index.html) 显示“它有效!”。

After configuring Apache and installing PHP, trying to load http:/localhost/phptest.phpi.e. (C:/testsite/htdocs/phptest.php).

配置Apache并安装PHP后,尝试加载http:/localhost/phptest.phpie (C:/testsite/htdocs/phptest.php)。

But this throws an error:

但这会引发错误:

Not Found. The requested URL /phptest.php was not found on this server.

未找到。在此服务器上找不到请求的 URL /phptest.php。

I also get the same error now loading

我现在加载时也遇到同样的错误

http://localhost

httpd.conf edits:

httpd.conf 编辑:

ServerName localhost:80

DocumentRoot "C:/testsite/htdocs"

<Directory "C:/testsite/htdocs">
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

LoadModule php5_module "c:/testsite/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/testsite/php"

File php.iniedits:

文件php.ini编辑:

include_path = ".;C:\testsite\php\includes"
extension_dir = "C:/testsite/php/ext/"

System path:

系统路径:

The PHP directory was added to the Windows path, e.g.

PHP 目录被添加到 Windows 路径中,例如

PATH=C:\Windows\System32;C:\many_dir;C:\testsite\php

The only errors in the Apache error.log are:

Apache error.log 中的唯一错误是:

Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2 /docs/dummy-host.localhost] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.localhost] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.localhost] does not exist

警告:DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2 /docs/dummy-host.localhost] 不存在
警告:DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy -host2.localhost] 不存在
警告:DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost] 不存在
警告:DocumentRoot [C:/Program Files/Apache Software Foundation] /Apache2.2/docs/dummy-host2.localhost] 不存在

The Apache service restarts successfully and is running. I can't find anything amiss. Can anyone spot any stupid errors?

Apache 服务成功重启并正在运行。我找不到任何不对劲的地方。任何人都可以发现任何愚蠢的错误吗?

回答by Janis Vepris

Try changing Deny from allto Allow from allin your conf and see if that helps.

尝试在您的 conf 中更改Deny from allAllow from all,看看是否有帮助。

回答by Masum billah

In httpd.conf file you need to remove #

在 httpd.conf 文件中,您需要删除 #

#LoadModule rewrite_module modules/mod_rewrite.so

after removing # line will look like this:

删除 # 行后将如下所示:

LoadModule rewrite_module modules/mod_rewrite.so

And Apache restart

和 Apache 重启

回答by T.Todua

Non-trivial reasons:

不平凡的原因:

  • if your .htaccessis in DOS format, change it to UNIX format (in Notepad++, click Edit>Convert)
  • if your .htaccessis in UTF8 Without-BOM, make it WITHBOM.
  • 如果你.htaccess是 DOS 格式,将其更改为 UNIX 格式(在 Notepad++ 中,单击Edit>Convert
  • 如果您使用的.htaccess没有-BOM 的UTF8 ,请使用BOM。

回答by KirstieBallance

I had the same problem, but believe it or not is was a case of case sensitivity.

我有同样的问题,但信不信由你是区分大小写的情况。

This on localhost: http://localhost/.../getdata.php?id=3

这在本地主机上: http://localhost/.../getdata.php?id=3

Did not behave the same as this on the server: http://server/.../getdata.php?id=3

在服务器上的行为与此不同: http://server/.../getdata.php?id=3

Changing the server url to this (notice the capital D in getData) solved my issue. http://localhost/.../getData.php?id=3

将服务器 url 更改为此(注意 getData 中的大写 D)解决了我的问题。 http://localhost/.../getData.php?id=3