Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peterson-umoke/7042049afc86451efc6b46a6c12ed7d0 to your computer and use it in GitHub Desktop.
Save peterson-umoke/7042049afc86451efc6b46a6c12ed7d0 to your computer and use it in GitHub Desktop.
How to remove the public path from laravel when using a shared server
We all know how painful it is to setup a beautiful application and then just discover that it sucks once it lands in your shared server. Here is how you can remove that annoying that annoying 'public' url path in your laravel application
1. change server.php in your root folder to index.php , no modifications pls
2. create a .htaccess file in your root folder
3. paste the code below
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /gidipaymentengine2/
# change above to your site i.e., RewriteBase /whatever/public/
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
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]
</IfModule>
Thanks for coming.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment