本文介绍了Laravel 5.1路由除了'/'以外不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/var/www/polyforms.me中创建了一个新的laravel项目,并创建了虚拟主机文件polyforms.conf:

I have created a new laravel project in /var/www/polyforms.me and created virtual host file polyforms.conf:

<VirtualHost *:80>
    ServerName polyforms.dev

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/polyforms.me/public

    ErrorLog ${APACHE_LOG_DIR}/polyforms.me-error.log
    CustomLog ${APACHE_LOG_DIR}/polyforms.me-access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

当我进入polyforms.dev时,它会按原样打开主页,但是当我进入polyforms.dev/about时,它会向我显示此内容:

When I go to polyforms.dev it opens home page as it should, but when I go to let's say polyforms.dev/about it shows me this:

如果我使用php artisan serve并使用http://localhost:8000/about,一切都很好...问题是什么以及如何解决?

If I use php artisan serve and use http://localhost:8000/about everything works fine... What is the problem and how to solve it?

推荐答案

我猜.htaccess被忽略了. http://httpd.apache.org/docs/2.2/en /mod/core.html#allowoverride

I guess .htaccess is ignored. http://httpd.apache.org/docs/2.2/en/mod/core.html#allowoverride

<VirtualHost *:80>
    ServerName polyforms.dev

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/polyforms.me/public

    <Directory "/var/www/polyforms.me/public">
      AllowOverride all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/polyforms.me-error.log
    CustomLog ${APACHE_LOG_DIR}/polyforms.me-access.log combined
</VirtualHost>

这篇关于Laravel 5.1路由除了'/'以外不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 16:59