Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.1 routing not working except '/'

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

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:

enter image description here

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

like image 774
clzola Avatar asked Dec 09 '22 01:12

clzola


2 Answers

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>
like image 198
everyman Avatar answered Dec 11 '22 11:12

everyman


Do you have a .htaccess file in the web root that points everything to index.php? If not, that's the problem (see the Laravel docs on what to add where). If so, Apache may be configured to deny .htaccess overrides. In that case you'll need to add a segment in your VirtualHost configuration allowing those. See the Apache documentation for more information. It also may be the case that mod_rewrite is not enabled. If using Ubuntu, Debian or other Debian-based OS is used a sudo a2enmod rewrite followed by sudo service apache2 reload will suffice.

like image 43
Plenka Avatar answered Dec 11 '22 10:12

Plenka