Mac – 127.0.0.1 is working but localhost is not working on mac XAMPP

apache-2.2localhostmacxampp

I installed XAMPP on my mac months ago and was working great.

Now i get "Test Page For Apache Installation" when i try to browse /localhost

and /localhost/xampp is not found.

But when i browse /127.0.0.1 it just works as localhost used to be.

I double checked my /etc/hosts file that i have 127.0.0.1 localhost and not commented.

Also when i browse localhost/~username/test.php , i get contents of test.php:

<?php echo 'ganim'; ?>

but if i browse 127.0.0.1/~username/test.php , i get:

ganim

what could change redirecting of localhost or how can i get localhost work again?

Best Answer

Maybe the OS X built-in web server is active and managed to bind to localhost, while XAMPP managed to bind to 127.0.0.1? Try turning off Web Sharing in System Preferences and restart XAMPP.