Resolving "Not Found" Errors After Migrating Apache Configuration on Windows
When you modify the httpd.conf file to point a new virtual host or directory structure at a specific path, it is common for the DocumentRoot warnings to appear initially. However, if those warnings persist alongside a 403 Forbidden error for your main site and a 404 Not Found error for PHP files, the issue usually lies in how Apache interprets access control directives relative to the new root.
In the scenario described, the user successfully loads http://localhost initially because the default installation uses C:/Program Files/Apache2.2/htdocs. After changing the DocumentRoot directive to C:/testsite/htdocs, the server returns a 403 error for the root URL and a 404 for /phptest.php. The error log confirms that Apache is still trying to serve from the old default paths for virtual host definitions, but the critical failure preventing access to the new site is the configuration within the <Directory> block.
The specific configuration causing the issue is:
<Directory "C:/testsite/htdocs">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
The directive Deny from all inside this block explicitly blocks every request targeting files within C:/testsite/htdocs. Apache processes this rule after determining the DocumentRoot. Since the user wants to access http://localhost/phptest.php, which resides in that directory, the server denies access before it even attempts to execute the PHP module or check file existence. This results in a "Not Found" or "Forbidden" response depending on the exact error handling chain, but functionally, the resource is inaccessible.
To resolve this, you must change the access control rules to allow requests from the local host. The Order and Deny directives are part of the legacy Apache 2.2 syntax. In modern configurations (Apache 2.4+), these were replaced by Require, but since this is an Apache 2.2 setup, the correct fix involves adjusting the order to allow first, then deny specific IPs if necessary, or simply allowing all traffic for a local development environment.
Here is the corrected configuration for the directory:
<Directory "C:/testsite/htdocs">
Options FollowSymLinks
AllowOverride None
# Allow all requests by default
Order allow,deny
Allow from all
</Directory>
This change instructs Apache to permit any request (Allow from all) rather than blocking them. If you intended to restrict access but encountered a "Not Found" error instead of "Forbidden," the root cause was likely that the Deny rule prevented the server from resolving the file path correctly in conjunction with other module conflicts, though typically it would return 403. In this specific case, the user reports getting "Not Found," which can happen if the directory permissions or the presence of a default index prevents listing, but the primary blocker is the explicit denial.
Additionally, ensure that the php5apache2_2.dll module is correctly loaded and that the path provided in LoadModule matches exactly where the DLL resides. If the DLL path is incorrect, Apache might load without PHP support, causing static files to work (if allowed) but PHP scripts to fail with internal errors or 404s if the file extension handler isn't registered. The AddType application/x-httpd-php .php directive ensures that requests ending in .php are passed to the PHP interpreter rather than being returned as plain text or treated as missing resources.
Finally, verify that the PHPIniDir points to a valid location where php.ini exists. If the file is missing or the paths in extension_dir do not contain the required .so or .dll files (such as php_mbstring.dll), Apache will fail to load the PHP core, potentially causing script execution to fail silently or return errors. Restarting the Apache service after these changes is essential for the new directives to take effect.