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.
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.
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:
- Guide to check XAMPP version on Windows.
- Default .htaccess file for WordPress website ?
- PHP-FastCGI on Windows in XAMPP for PHP Performance
- PHP FPM – Check if Installed and Running
- XAMPP Error: MySQL shutdown unexpectedly
- With UAC please avoid installing XAMPP to C:\Program Files warning ?
- Best way to delete components in Angular 9 with CLI
- Dynamic and conditional CSS classes with ngClass : Angular
- Best way to delete components in Angular 9 with CLI ?
- HTML Property Binding in Angular : Data Binding
- Quickly create div classes in Visual Studio Code editor
- Global Angular CLI version is greater than your local version
- Create custom events and fire in Angular 9 with EventEmitter – Example
- Bind selected element from drop down to an object in Angular 9
- How to stop generation of .spec.ts test files using Angular CLI ?
Thank you very much, you solved my problem.
It helped, thank you very much!