Basically I need to remove index.php
or public/index.php
from the the generated URL in laravel, commonly path is localhost/public/index.php/someWordForRoute
, It should be something like localhost/someWordForRoute
htacces
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
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]
app/config/app.php
'url' => 'http://localhost',
how can I change that?
I tried this on Laravel 4.2
Rename the
server.php
in the your Laravel root folder toindex.php
and copy the.htaccess
file from/public
directory to your Laravel root folder.I hope it works
Hope this helps like it did for me.
For Laravel 4 & 5:
Thats it !! :)
1) Check whether mod_rewrite is enabled. Go to
/etc/apache2/mods-enabled
directory and see whether therewrite.load
is available. If not, enable it using the commandsudo a2enmod rewrite
.It will enable the rewrite module. If its already enabled, it will show the messageModule rewrite already enabled
.2)Create a virtual host for public directory so that instead of giving
http://localhost/public/index.php
we will be able to use like thathttp://example.com/index.php
. [hence public folder name will be hidded]3)Then create a .htaccess which will hide the index.php from your url which shoul be inside the root directory (public folder)
use this in .htaccess and restart the server