11
votes

I'm having what appears to be a common problem but any solutions I've found don't seem to work for my case.

I'm trying to set up a virtual host so that I can access the public file of my Laravel installation by going to "walkpeakdistrict.local" but when I type this address into google chrome I am always redirected to the xampp dashboard at this address "https://walkpeakdistrict.local/dashboard/".

I've installed Laravel in the following xampp directory: c:/xampp/htdocs/walkpeakdistrict_uk.

I have "C:\xampp\apache\conf\extra\httpd-vhosts.conf" set up as follows:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/walkpeakdistrict_uk/public"
    ServerName walkpeakdistrict.local
</VirtualHost>

And I have "C:\Windows\System32\drivers\etc\hosts" set up as follows:

127.0.0.1   localhost
127.0.0.1   walkpeakdistrict.local

If anyone could offer any insight into this issue I would be very grateful.

8
In the "httpd.conf", did you do Include "C:\xampp\apache\conf\extra\httpd-vhosts.conf? Also, have you restarted the web server when you made modifications?user7941334

8 Answers

6
votes

Ok, I'm not sure why this was an issue but it seems to work when I change the virtual host's server name to anything other than ".local".

Thanks again to all who replied!

5
votes

Put this as the first line in C:\...\httpd-vhosts.conf (and restart the web server):

NameVirtualHost *:80

So, it should look like this:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
    ServerName walkpeakdistrict.local
    DocumentRoot "C:/xampp/htdocs/walkpeakdistrict_uk/public"
</VirtualHost>

I would place all my projects somewhere outside of C:/xampp/htdocs and C:/xampp. Let C:/xampp/htdocs be the standard localhost location, with just two files inside (simple index.php and index.html), but use another one for the projects. Even better, use another partition, not the system partition C:. Like D:/projects, or so. So, you would have D:/projects/walkpeakdistrict_uk.

Good luck.

3
votes

I'm pretty sure the issue for me had to do with SSL redirects, for some reason. When I edited my .htaccess to exclude local.mydomain.com when forcing https, I stopped getting redirected to the XAMPP dashboard.

Below is the section of my .htaccess that excludes local sites from redirecting to https. You can add extra RewriteCond lines for other local domains.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !=localhost
    RewriteCond %{HTTP_HOST} !local\.
    RewriteCond %{HTTP_HOST} !other.localdomain.example.com
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
</IfModule>

<IfModule mod_headers.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !local\.
    RewriteCond %{HTTP_HOST} !other.localdomain.example.com
    Header set Strict-Transport-Security "max-age=16070400" env=HTTPS
</IfModule>
1
votes

This happened with me as well. And I resolved it. In my case, it was happening because of the SSL module. So, turning it off got me out of the trouble. Just Open the httpd.conf file and comment the SSL include code by adding # to the front of the code as given below.

# Secure (SSL/TLS) connections
# Include conf/extra/httpd-ssl.conf

After this, the will be resolved.

0
votes

Change your document root to this, just add a slash at the end of public and it will work

DocumentRoot "C:/xampp/htdocs/walkpeakdistrict_uk/public/"
0
votes

I had this problem after developing my website and I got round it by simply rebooting my machine. Many months later, Google then invalidated the use of .dev so my virtual host stopped working. I changed the name of my virtual host to .test and got the dashboard. I had forgotten the simple solution and arrived on this page searching for a solution. Then i remembered......I rebooted my machine and hey presto....it worked. No more dashboard. I get the right homepage.

0
votes

In your case, you put localhost settings in virtual host. check if you got this script on default file conf, then comment it. Case on xampp for mac

Include "${your_xampp_path}/conf/httpd.conf"
-2
votes

The solution is very simple, it always redirects the https url to the Dasboard, you just have to remove the s leaving http:

Example: http://juego123.com