xampp redirects to localhost/dashboard instead of directories and files

XAMPP browser redirects to localhost/dashboard

This tutorial guides you on XAMPP browser redirects to localhost/dashboard URL instead of seeing the directories and files listing before.

XAMPP browser redirects to localhost/dashboard

I had downloaded the latest version of XAMPP and Installed XAMPP on Windows. Then I had started Apache and MySQL servers as shown below.

Check XAMPP version on Windows

Afterwards, I typed “http://localhost” in the browser, then tried to open the localhost URL and expected directories and file listing as shown below. But instead it redirected me to “http://localhost/dashboard” page.

xampp redirects to localhost/dashboard instead of directories and files

You know I saw “index.php” in the”c:/xampp/htdocs” directory with the following contents. You could see that “index.php” is performing redirect using header(‘Location: ‘.$uri.’/dashboard/’);. Therefore, http://localhost is getting redirected to http://localhost/dashboard.

<?php
	if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
		$uri = 'https://';
	} else {
		$uri = 'http://';
	}
	$uri .= $_SERVER['HTTP_HOST'];
	header('Location: '.$uri.'/dashboard/');
	exit;
?>
Something is wrong with the XAMPP installation :-(

XAMPP localhost list directories and files

The solution to list directories and files when you open “http://localhost” URL from browser is, you just need delete the “index.php” inside htdocs or on the safer side I would recommend you to rename it to some other name like “index1.php“. You can see in the above picture that I had renamed “index.php” file with “index1.php”.

Finally, I could see opening “http://localhost” URL resulted in listing directories and files as shown above.

Note, if you wanted to redirect to your project folder instead of directories and files listing, then instead of renaming you can modify the header location to point to your project directory. For example, in my case I have pointed it to /sneppets/ instead of /dashboard/ as shown below.

<?php
	if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
		$uri = 'https://';
	} else {
		$uri = 'http://';
	}
	$uri .= $_SERVER['HTTP_HOST'];
	header('Location: '.$uri.'/sneppets/');
	exit;
?>
Something is wrong with the XAMPP installation :-(

The above modification will result in redirecting you to http://localhost/sneppets whenever you hit http://localhost URL in the browser.

That’s it. Hope it helped 🙂

Also See:

References:

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Gonzalo
Gonzalo
2 years ago

Thank you very much, you solved my problem. 

anon
anon
2 years ago

It helped, thank you very much!