Tag Archives: htaccess

Remove public URL on shared hosting | Laravel

Laravel out of the oven is not prepared for being deployed on shared hosting.

I often use shared hosting for testing web apps as it’s the easiest and fastest way of having an app running in WWW.
See bellow what changes are required in order to make Laravel work on shared hosting.

First step is to complete the Laravel setup. You’ll notice that you can access the app by placing /public/ in the URL. This is obviously not fancy at all.

Fix it by replacing the content of .htaccess in the root directory with the code bellow:

<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{REQUEST_URI} !^public
	RewriteRule ^(.*)$ public/$1 [L]

That’s all. Remove the /public/ and refresh.

Check my other Laravel posts.