Just updated to 5.1.16 on my local install and everything seems to work fine with my pretty URL's ie. example.com and example.com/auth/login and example.com/home all work fine.
When I try to install on Ubuntu 14.04 Apache 2.4.7 it seems that the htaccess rewrite is not working for the URL's like example.com/auth/login and example.com/home
In order for these to work then I have to put in example.com/index.php/auth/login or example.com/index.php/home for any of these to work.
My htaccess in the laravel public folder looks like this:
# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index.php/?(.*)$ $1 [R=301,L]
</IfModule>
I have tried some different solutions and all seem to not work. Any help would be greatly appreciated. btw: I started with this as the rewrite rule: RewriteRule ^ index.php [L] which also did not work and thus the change to above.
I always see that if mod_rewrite line - is it possible you don't have apache configured with mod_rewrite? therefor none of the rewrite conditions would work?
mod_rewrite is indeed enabled, but it does seem that the rewrite conditions are simply not being considered.
I solved this after some digging around and this is out there in different forms of solutions, but here is mine for other noobs out there that might struggle with figuring it out:
On Apache 2.4.7 then the default config is to use the /var/www/ to put your website html ie. your laravel install. The apache2.conf is also set to not allow .htaccess override by setting AllowOverride None like this
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Well you can change this by changing the apache2.conf, but this is not recommended due to the chance of it being overwritten by apache2 upgrades, etc. Instead of changing this then it is recommended to do this override in the VirtualHosts file for your site ie. sites-available/yoursite.com.conf
In this file then you need the above directive with the value for the directory right into your public folder on Laravel ie. /var/www/html/yoursite.com/laravelappinstall/public It should look something like this:
<Directory /var/www/html/yoursite.com/laravelappinstall/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Put that in yoursite.com.conf (Virtual Hosts config), make sure your .htaccess from in that folder looks just like the one from the Laravel install documentation Pretty URLs
Make sure that you have enabled the rewrite module ie. sudo a2enmod rewrite
Restart your web server ie. sudo service apache2 restart
And voila! You should be back in business with pretty url's. It is at least what finally worked for me and puts all of the info that I needed to find in different threads and piece together to finally make sense of what was going on. Hope it might help another noob!
Long live Laravel!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community