The classic "redirect to XAMPP localhost directory" issue!
This problem usually occurs when you're trying to run a PHP application (e.g., Laravel, CodeIgniter, WordPress, etc.) on a local development environment using XAMPP, but instead of loading your app, the browser redirects you to the XAMPP dashboard (http://localhost/xampp/, http://localhost/dashboard/, or just http://localhost/ showing the directory listing).
Here are the top reasons and fixes to resolve this issue:
Reason 1: Incorrect DocumentRoot and <Directory> settings in Apache configuration
In XAMPP, Apache's configuration file httpd.conf (or apache2.conf on Linux/Mac) defines the document root and directory settings.
Fix:
- Open the XAMPP Control Panel.
- Click on Apache > Config > httpd.conf (or edit the file manually:
C:\xampp\apache\conf\httpd.conf on Windows or /Applications/XAMPP/xamppfiles/etc/httpd.conf on Mac).
- Search for
DocumentRoot and <Directory> lines. You should see something like:
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
- Update these lines to point to your project's public folder (e.g.,
C:/xampp/htdocs/myapp/public):
DocumentRoot "C:/xampp/htdocs/myapp/public"
<Directory "C:/xampp/htdocs/myapp/public">
For Laravel projects, use myapp/public (where myapp is your Laravel project folder). For other frameworks/apps, adjust accordingly (e.g., myapp/www, myapp/htdocs, etc.).
5. Restart Apache from the XAMPP Control Panel.
Reason 2: Missing or incorrect index.php or index.html in your project root
Apache looks for index.php or index.html to serve as the default entry point. If none exist or are misconfigured, it falls back to the XAMPP dashboard.
Fix:
- Ensure your project has a valid entry point file (
index.php for PHP apps):
- For Laravel:
myapp/public/index.php should exist.
- For other PHP apps: verify
index.php is in your project root or public folder.
- If using a framework, double-check the routing configuration (e.g., Laravel's
routes/web.php).
Reason 3: .htaccess file issues (Apache rewrite rules)
A misconfigured or missing .htaccess file can cause redirects to the XAMPP dashboard.
Fix:
- Check if your project has a
.htaccess file in the public folder (e.g., myapp/public/.htaccess).
- For Laravel, the default
.htaccess should contain:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
- If the file is missing or incorrect, create/restore the proper
.htaccess for your framework/app.
Reason 4: Virtual Hosts (vhosts) not configured
If you're using multiple projects, setting up Virtual Hosts helps Apache distinguish between them.
Fix:
- Open
C:\xampp\apache\conf\extra\httpd-vhosts.conf (Windows) or /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf (Mac).
- Add a new Virtual Host entry for your project:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/myapp/public"
ServerName myapp.local
<Directory "C:/xampp/htdocs/myapp/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
- Edit your hosts file (
C:\Windows\System32\drivers\etc\hosts on Windows or /etc/hosts on Mac/Linux):
127.0.0.1 myapp.local
- Restart Apache.
Additional steps:
- Clear browser cache (try a different browser or
Ctrl + Shift + R to hard-refresh).
- Double-check XAMPP is running Apache and MySQL services.
- If using Laravel, run
php artisan serve in your project root as an alternative (starts a development server on http://localhost:8000).
Now, try accessing your app via:
http://localhost (if you updated DocumentRoot)
http://myapp.local (if you configured Virtual Hosts)
http://localhost/myapp/public (adjust to your project folder)
Still stuck? Verify:
- No other web servers (e.g., IIS, Nginx) are running on port 80.
- No firewall rules are blocking Apache.
- Your project's file permissions are correct (try running XAMPP as Administrator).
Hope one of these solutions redirects you to your app, not the XAMPP dashboard!