Why Changing the Document Root Alone Isn't Enough in XAMPP
You have configured your httpd.conf file to point to C:/users/matt/documents/web/, yet accessing http://localhost/test/ or any variation thereof fails to load files from your Eclipse workspace. This is a classic misunderstanding of how Apache's document root interacts with virtual hosts and URL rewriting rules, not just a matter of changing one string in the configuration file.
When you set the DocumentRoot directive to C:/users/matt/documents/web/, you are telling Apache where to look for files when a request hits that specific server block. However, if your default site (often named default or localhost) is still pointing to the legacy XAMPP directory (xampp/htdocs), changing the root in one place doesn't automatically redirect all traffic there. Apache relies on multiple configuration layers: the main config file, included virtual host files (usually found in conf/extra/httpd-vhosts.conf), and potentially a .htaccess override.
If you modified httpd.conf directly but did not restart the server or if an included file is overriding your settings, the browser will still serve content from the original directory. To verify this, check for a <VirtualHost> block specifically configured for localhost. If it contains DocumentRoot "C:/xampp/htdocs", that setting takes precedence over any global changes made in httpd.conf unless you are using specific flags that don't apply to standard setups.
The most robust way to fix this is to define a virtual host explicitly. Open conf/extra/httpd-vhosts.conf (or create it if it doesn't exist) and add the following block:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/users/matt/documents/web/test"
<Directory "C:/users/matt/documents/web/test">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This configuration ensures that any request to localhost is served from your intended workspace directory. The Require all granted directive inside the <Directory> block is critical; without it, Apache denies access regardless of the document root setting. Additionally, ensure that AllowOverride All is set if you plan to use .htaccess files for URL rewriting or framework routing.
A common pitfall involves URL paths relative to the document root. If your DocumentRoot is set to C:/users/matt/documents/web/, then accessing http://localhost/test/ will look for a file at C:/users/matt/documents/web/test/index.php (or equivalent). If you intended the URL http://localhost/test/ to map directly to the folder test, your DocumentRoot must point exactly to that subfolder, not the parent directory. Mismatching these paths results in 403 Forbidden or 404 Not Found errors because Apache is looking in the wrong place relative to the requested URL.
After modifying any Apache configuration, a simple restart via the XAMPP Control Panel is often insufficient if permissions are involved. On Windows, ensure that Eclipse has read/write permissions to the workspace directory, as some development environments (like PHP servers running inside IDE plugins) may cache file lists or fail to detect new files without a full service reset.
If you are building a Laravel application within this structure, consider pointing your virtual host specifically to the public subdirectory of your project, which is standard practice for modern PHP frameworks. This isolates the framework's entry point and prevents direct access to sensitive files outside the web root. While XAMPP is excellent for local development, production environments typically require more granular control over server blocks and security headers, resources that can be explored further in dedicated guides like those from LaravelCompany for best practices on deploying Laravel applications.
Ultimately, the issue isn't just about changing a string; it's about ensuring every layer of your Apache configuration aligns with your desired URL structure and file system layout.