[英]laravel 5.3: setup virtual host. Getting Apache 404 error
I want to setup a virtual host in my localhost, so I can access my Laravel app like this: demo.example.com
. 我想在本地主机中设置虚拟主机,因此可以访问Laravel应用程序:
demo.example.com
。 I have added a custom conf
file: etc/apache2/sites-available/example.com.conf
with the following contents: 我添加了一个自定义
conf
文件: etc/apache2/sites-available/example.com.conf
,其内容如下:
<VirtualHost *:80>
ServerAdmin username@gmail.com
ServerName example.com
ServerAlias www.example.com
ServerAlias demo.example.com
ServerAlias www.demo.example.com
DocumentRoot /var/www/example/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example/public>
AllowOverride All
</Directory>
</VirtualHost>
Contents from /etc/hosts
file: /etc/hosts
文件中的内容:
127.0.0.1 localhost
127.0.1.1 username-pc
127.0.0.1 example.com
127.0.0.1 www.example.com
127.0.0.1 http://exaple.com
127.0.0.1 demo.example.com
With the above settings if I access the url demo.example.com
it works. 使用以上设置,如果我访问URL
demo.example.com
它就可以工作。 But if I try to access other routes like demo.example.com/login
I get apache 404 error: The requested URL /login was not found on this server. 但是,如果我尝试访问其他路由,例如
demo.example.com/login
收到apache 404错误: 在此服务器上找不到请求的URL / login。 How do I fix this? 我该如何解决?
Note that this is not laravel's NotFoundHttpException . 请注意,这不是laravel的NotFoundHttpException 。
place this under your directory tag 将此放置在您的目录标签下
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.