Edgar Sampere Edgar Sampere - 1 year ago 103
PHP Question

Routes not working on server using Laravel 5.2

I'm deploying a webapp to a digitalOcean droplet and it displays the home route just fine. I have dependencies installed, Apache conf pointing to laravel's public folder, permissions given to

so Apache can use the folder but, when I try to access a link defined in the site, already defined in the routes file, for example
I get a 404 error.

Why could this be?

The droplet's runs Ubuntu 16.04, I have Apache and php7.

I was reading this two posts: 1 and 2 but got no luck

My apache conf file is

<Directory /var/www/html/analizalabs/public>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted

My sites-available file

ServerAdmin tecnofunk@cryptolab.net
DocumentRoot /var/www/html/analizalabs/public/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Part of my routes file


My htaccess file

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Permissions like...

drwxrwxr-x 8 www-data dev 4096 Sep 9 21:58 public

is the group I use to modify files with rw access in that directory.

Answer Source

It seems rewrite module isn't enabled, You have to enable it using:

a2enmod rewrite

Note1: rewrite module is not enabled by default in ubuntu

Note2: You can check enabled modules with apache2ctl -M and apachectl -M in mac ( or httpd -M in both )

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download