blankBird_ blankBird_ - 2 months ago 22x
PHP Question

Laravel 5.2 Pretty URLs

How can i change to and can get the other routes working other than


Workaround 1:

vhost file:

<VirtualHost *:80>
DocumentRoot "/var/www/html/domain/public"
<Directory "/var/www/html/domain/public">
AllowOverride All
Allow from All

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

htaccess file:

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

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

With this setup, yes i'm able to set but when i'm trying to invoke another route, getting a 404. The reason behind this is as you can see i've set my root folder as public. So my routes cannot reach their destinations (like the ones which are being directed to my controllers, because my controllers are not in the public folder).

Workaround 2:

If i change Document root and directory into
this time i'm losing my pretty url and only way i can request main page by entering

Note that I'm using ubuntu 14.04.

What do you suggest?


Route example:

Route::get('myroute', array(
'uses' => 'MyController@myMethod',
'as' => 'myroute'

---update 2---
php artisan route:list results are

| Domain | Method | URI | Name | Action | Middleware |
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | myroute | | Closure | web |


Yes, each of those answers are nicely working, but before that I found out apache rewrite module mod_rewrite should have already been activated.

On ubuntu console: a2enmod rewrite solved my situation.