Apache virtual host always redirecting to /dashboard
Asked Answered
T

13

16

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 "mytestdomain.local" but when I type this address into google chrome I am always redirected to the xampp dashboard at this address "https://mytestdomain.local/dashboard/".

I've installed Laravel in the following xampp directory: c:/xampp/htdocs/mytestdomain_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/mytestdomain_uk/public"
    ServerName mytestdomain.local
</VirtualHost>

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

127.0.0.1   localhost
127.0.0.1   mytestdomain.local

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

Transposition answered 30/1, 2018 at 3:10 Comment(1)
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?Hilton
T
6

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!

Transposition answered 30/1, 2018 at 18:17 Comment(4)
OMG, i was fighting with this two days. Thank you. Now I lefted it without any .COM or .DEV or .LOCAL and it work perfect.Harbinger
Thanx @Transposition I spent 10 hours figuring out why virtualhost getting redirected to xampp dashboard when server name was set to site.local, but when I changed it to site.localhost it worked perfectly.Senaidasenalda
I just encountered this in 2021... >.< Still not sure why this is happening.Phylloid
how did you do it?Rosaleerosaleen
H
8

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.

Hilton answered 30/1, 2018 at 4:0 Comment(2)
Thank you for the response, I've tried this and restarted apache but unfortunately it still seems to want to redirect me to the dashboard.Transposition
@Transposition You are welcome. Good that it works now... even without .local. Don't forget to mark your own answer as "accepted", in a few days, so that other users can benefit from your solution. Bye.Hilton
H
7

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>
Hostetler answered 27/4, 2018 at 20:10 Comment(2)
where is this file located?Aniconic
@Aniconic Here's some info for you! danielmorell.com/guides/htaccess-seo/basics/…Hostetler
T
6

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!

Transposition answered 30/1, 2018 at 18:17 Comment(4)
OMG, i was fighting with this two days. Thank you. Now I lefted it without any .COM or .DEV or .LOCAL and it work perfect.Harbinger
Thanx @Transposition I spent 10 hours figuring out why virtualhost getting redirected to xampp dashboard when server name was set to site.local, but when I changed it to site.localhost it worked perfectly.Senaidasenalda
I just encountered this in 2021... >.< Still not sure why this is happening.Phylloid
how did you do it?Rosaleerosaleen
C
6

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, it will be resolved.

Curler answered 24/1, 2021 at 16:10 Comment(1)
This worked for me. SSL redirect was the problemAeneus
K
1

I came here with the same problem, in my case accessing the website through http instead https worked.

In browser, instead of accessing this way:

https://mytestdomain.loc

try this one

http://mytestdomain.loc
Kamilahkamillah answered 16/9, 2022 at 9:52 Comment(0)
C
1

Its works for me once I remove header location from 'htdocs/index.php' file enter image description here

Conduit answered 9/2, 2023 at 10:29 Comment(1)
this worked for me on a laravel app, running on xampp apache with a virtual hostHelainehelali
E
0

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/"
Eigenvalue answered 24/9, 2018 at 7:17 Comment(1)
This is not what the OP askPariah
T
0

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.

Trunnel answered 26/9, 2018 at 20:8 Comment(0)
G
0

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"
Glisson answered 30/10, 2020 at 11:6 Comment(0)
S
0

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

Stableman answered 20/3, 2021 at 10:38 Comment(1)
that worked for me, in new projects the virtual host was working but the older ones which were unused for a long time there this problem of redirecting to xampp dashboard was occurringLarrikin
H
0

I was facing the same error. I solved the error by removing the *80 port number from the virtual host tag and then my code look like

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

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

**NOTE:**Your Virtual Host tag looks like this <VirtualHost *> This means we are redirecting to any other port or not bounding the virtual host to port 80 this will work definitely.

Hemimorphic answered 14/4, 2022 at 6:53 Comment(0)
F
0

Perhaps, possible reason is no vhost in httpd-ssl. If so, add a vhost in your httpd-ssl.conf like, for example:

<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs/mytestdomain_uk/public"
    ServerName mytestdomain.local

    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "conf/ssl.key/server.key"
</VirtualHost>

Above configuration is just an example. You need to change accordingly.

Forrester answered 30/1 at 10:58 Comment(0)
S
0

In my case, I was able to solve this issue by adding this record:

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

Pretty easy to miss IMO.

Stationer answered 6/8 at 21:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.