Skip to content

Instantly share code, notes, and snippets.

@aceraven777
Created July 4, 2019 07:37
Show Gist options
  • Save aceraven777/f82871a63e89d7c564bb11eb8c5b64c0 to your computer and use it in GitHub Desktop.
Save aceraven777/f82871a63e89d7c564bb11eb8c5b64c0 to your computer and use it in GitHub Desktop.
Laravel .htaccess file if you can't change the document root
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^dashboard.liveablecities.ph$ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST} [L,R]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^(css|js|images|storage)/(.*)$ /public/index.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(css|js|images|storage)/(.*)$ /public/$1/$2 [L,NC]
RewriteRule ^favicon.ico$ /public/favicon.ico [L,NC]
RewriteRule ^mix-manifest.json$ /public/mix-manifest.json [L,NC]
RewriteRule ^robots.txt$ /public/robots.txt [L,NC]
RewriteRule ^web.config$ /public/web.config [L,NC]
# If Laravel root files are accessed, use the /public/index.php file
RewriteRule ^.env /public/index.php [L,NC]
RewriteRule ^artisan /public/index.php [L,NC]
RewriteRule ^composer.json /public/index.php [L,NC]
RewriteRule ^composer.lock /public/index.php [L,NC]
RewriteRule ^package.json /public/index.php [L,NC]
RewriteRule ^phpunit.xml /public/index.php [L,NC]
RewriteRule ^readme.md /public/index.php [L,NC]
RewriteRule ^server.php /public/index.php [L,NC]
RewriteRule ^webpack.mix.js /public/index.php [L,NC]
RewriteRule ^.editorconfig /public/index.php [L,NC]
RewriteRule ^.gitattributes /public/index.php [L,NC]
RewriteRule ^.gitignore /public/index.php [L,NC]
# If Laravel directories are accessed, use the /public/index.php file
RewriteRule ^app(/|$) /public/index.php [L,NC]
RewriteRule ^bootstrap(/|$) /public/index.php [L,NC]
RewriteRule ^config(/|$) /public/index.php [L,NC]
RewriteRule ^database(/|$) /public/index.php [L,NC]
RewriteRule ^resources(/|$) /public/index.php [L,NC]
RewriteRule ^routes(/|$) /public/index.php [L,NC]
RewriteRule ^storage(/|$) /public/index.php [L,NC]
RewriteRule ^tests(/|$) /public/index.php [L,NC]
RewriteRule ^vendor(/|$) /public/index.php [L,NC]
RewriteRule ^.git(/|$) /public/index.php [L,NC]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment