简体   繁体   中英

Apache virtual host always redirecting to /dashboard

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.

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!

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.

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>

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.

将您的文档根目录更改为此,只需在 public 末尾添加一个斜杠即可

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

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.

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"

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.

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

I imagine you have figured the issue out by now but for anybody else who ever stumbles upon this question here is the most common answer.

On the XAMPP control panel, if you edit the httpd-vhosts.conf file whilst Apache is still running, it will continue running the previous version of the file through it's cache so the solution to this is to restart Apache through the XAMPP control panel .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM