简体   繁体   中英

Laravel virtual host on Xampp does not work out properly

I want to load my Laravel 5.8 project with Virtual Host on XAMPP. So here is what I did:

I opened up C:\\Windows\\System32\\drivers\\etc\\hosts and put this:

#   127.0.0.1       localhost
#   ::1             localhost
    127.0.0.1       local.nanoclub.ir

Then at C:\\xampp\\apache\\conf\\extra\\httpd-vhosts.conf , I added this:

<VirtualHost local.nanoclub.ir:80>
    DocumentRoot "C:/xampp/htdocs/badges/public"
    ServerName local.nanoclub.ir
    ServerAlias *.local.nanoclub.ir
    SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp/htdocs/badges/public">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>    
</VirtualHost>

And also added this to my project, public .htaccess :

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

But now when I want to run local.nanoclub.ir on browser, I get this:

在此处输入图片说明

I also tried adding this to C:/xampp/apache/conf/httpd.conf but still the same page appears:

<Directory C:/xampp/htdocs/badges/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

So what's going wrong here? I used to access this local.nanoclub.ir correctly but now it loads this screen.

How to solve this issue?

if you are using windows 10 then please follow this steps :-

First, you need to navigate to C:\\xampp\\apache\\conf\\extra or wherever your XAMPP files are located. In my case, my XAMPP file is located in drive D.

Then, edit httpd-vhosts.conf with any text editor.

<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:\xampp\htdocs\badges\public"
ServerName farhan.cw
<Directory "C:\xampp\htdocs\badges\public">
</Directory>
</VirtualHost>

Now, go to Windows > Search > Run and paste the following line:

C:\\Windows\\System32\\drivers\\etc\\hosts

Next, open the Host file in your text editor and add the following line in the Host file.

127.0.0.1 local.nanoclub.ir

Once you are done, you need to restart Apache and MySQL from the XAMPP control panel.

Then open url url : http://local.nanoclub.ir

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