Monday 16 May 2016

Laravel 5 - Remove public from URL

For Laravel 5:

Follow steps below to remove "public" word from URL,

1) Rename the server.php in the your Laravel root folder to index.php

2) Copy .htaccess file from /public directory to your Laravel root folder.

3) Changing .htaccess file as follows for statics:


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
 


If there are any other static files needed just add the extension to the previous declared list

And now its done!!!

 

3 comments:

  1. Wonderful blog! Thanks for sharing the information on the blog. Magento Development Companies in Bangalore

    ReplyDelete
  2. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation. Hire laravel developers UK

    ReplyDelete
  3. Great Article so thanks for sharing your article it will be helpful for me please check here hire laravel developer | full stack web developer

    ReplyDelete