Skip to content

Instantly share code, notes, and snippets.

@cdsaenz
Created March 19, 2022 02:20
Show Gist options
  • Save cdsaenz/4a765e57a8b76f1beef47d21b8bcd4fd to your computer and use it in GitHub Desktop.
Save cdsaenz/4a765e57a8b76f1beef47d21b8bcd4fd to your computer and use it in GitHub Desktop.
Laravel .htaccess to remove public without anything else. Tested in Laravel 8.
# Source is https://stackoverflow.com/a/48494280/827376
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment