.htaccess for Laravel

I was just playing around with a Laravel installation on free hosting.

Normally, you should change the document root of your website to the public folder with Laravel. You can’t do this on free hosting, but you can simulate this with .htaccess rules. These are the the .htaccess rules I used:

RewriteEngine On
RewriteRule (.*) /public/$1 [L]

Simply create a file with the name .htaccess and these contents and upload it directly to your htdocs folder. This should rewrite all web requests to the public folder, without showing this in the URL or potentially exposing system files.

5 Likes

I finally found my answer (not related to laravel) after long time! Thank you :smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.