Explore Blog Post below

Laravel HtAccess How to Remove Index.php from Url

Posted in Code Snippets on Sep 13, 2015

To remove the "index.php" suffix from the end of your Laravel applications url, use one of the two methods below.

This also works for removing the public from your url

Method1. At the minimum use the following code and put it in your "public" folder inside an htaccess file. Make the public folder the root of your application.



    Options -MultiViews
    RewriteEngine On

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


Method2. If you do not have access to change you application's root folder to public, put the following code in your application's root directory(which presumably is the one where public is contained in) inside of a .htaccess file.



    Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]


These snippets assume that you are not using IIS server but apache. If you are using IIS, drop me a line in the comments below and I'd be happy to help.