[php] Apache: The requested URL / was not found on this server. Apache

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.,

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

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

But this throws an error:

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

I also get the same error now loading

http://localhost

httpd.conf edits:

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.ini edits:

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.

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

The only errors in the Apache error.log are:

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

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

This question is related to php windows apache url http-status-code-404

The answer is


Try changing Deny from all to Allow from all in your conf and see if that helps.


Non-trivial reasons:

  • if your .htaccess is in DOS format, change it to UNIX format (in Notepad++, click Edit>Convert )
  • if your .htaccess is in UTF8 Without-BOM, make it WITH BOM.

In httpd.conf file you need to remove #

#LoadModule rewrite_module modules/mod_rewrite.so

after removing # line will look like this:

LoadModule rewrite_module modules/mod_rewrite.so

And Apache restart


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

Did not behave the same as this on the server: 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


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to apache

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer

Examples related to url

What is the difference between URL parameters and query strings? Allow Access-Control-Allow-Origin header using HTML5 fetch API File URL "Not allowed to load local resource" in the Internet Browser Slack URL to open a channel from browser Getting absolute URLs using ASP.NET Core How do I load an HTTP URL with App Transport Security enabled in iOS 9? Adding form action in html in laravel React-router urls don't work when refreshing or writing manually URL for public Amazon S3 bucket How can I append a query parameter to an existing URL?

Examples related to http-status-code-404

Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Vue-router redirect on page not found (404) Apache: The requested URL / was not found on this server. Apache Tomcat Servlet: Error 404 - The requested resource is not available Django, creating a custom 500/404 error page TOMCAT - HTTP Status 404 Object not found! The requested URL was not found on this server. localhost Getting 404 Not Found error while trying to use ErrorDocument Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available" MIME types missing in IIS 7 for ASP.NET - 404.17