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:
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?
You need to grant access to this directory.
You can grant this access in your virtual host definition or in the apache2.conf
<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
# The missing one
Require all granted
</Directory>
</VirtualHost>
<Directory C:/xampp/htdocs/badges/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Notice: Don't forget to restart apache after changing configuration.