php - Xampp 上的 Laravel 虚拟主机无法正常工作
问题描述
我想在 XAMPP 上使用虚拟主机加载我的 Laravel 5.8 项目。所以这就是我所做的:
我打开C:\Windows\System32\drivers\etc\hosts
并放了这个:
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 local.nanoclub.ir
然后在C:\xampp\apache\conf\extra\httpd-vhosts.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
</Directory>
</VirtualHost>
并将其添加到我的项目 public 中.htaccess
:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
但是现在当我想local.nanoclub.ir
在浏览器上运行时,我得到了这个:
那么这里出了什么问题?我以前可以正确访问它local.nanoclub.ir
,但现在它加载了这个屏幕。
如何解决这个问题?
解决方案
您需要授予对此目录的访问权限。
您可以在虚拟主机定义或 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>
在 apache2.conf
<Directory C:/xampp/htdocs/badges/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
注意:更改配置后不要忘记重新启动 apache。
推荐阅读
- c# - 来自用户输入字段的唯一字母 c#
- python - 带有python的Sharepoint日历api
- python - 如果它们之间存在匹配,如何从第二个df中获取一个项目
- c++ - 静态成员函数中的返回值类型自动推导失败
- docker - 使用 jnlp-slave 的打包机的 Dockerfile
- swift - 如何运行多个 NSRegularExpression 一次
- java - 查找数字的 sqrt
- c - 如何输入大小未知的字符串
- amazon-web-services - IPA 服务器的 UI 没有出现在 AWS ec2 实例上?
- python - 使用变量执行用yaml编写的python脚本