How to Host your Laravel Project on a shared Hosting.

Hosting your Laravel Project on a shared Hosting can be a little bit tricky sometimes especially if you are new to the Framework. This article will guide you through hosting your Laravel Project on a shared Hosting. There are two ways of going about this, feel free to choose the one that best suits your need.


Add your app domain as an addon domain by following the steps below:

  1. Login into your hosting account.
  2. Click on the domain Tab
  3. Locate the “Assign a domain to your Control Panel account”
  4. Follow the instruction as given by your hosting account, when your get to where you choose the addon directory, make sure the directory points to the directory of your Laravel app slash public. That is; if your app is hosted in “mylaravelapp” then your addon directory will be “mylaravelapp/public”
  5. And that’s it.


This method is for those of us whose app domain is actually the main domain of our hosting account.

    1. Login into your hosting account
    2. Scroll down to the Files section.
    3. Click the File Manager icon.
    4. Check the View Hidden Files checkbox.
    5. You are working with your primary domain, so select the WebRoot (public_html/www) option.
    6. Right click the .htaccess file, if one exist and choose Code Editor. If no .htaccess found create one
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ subdirectory/index.html [L]
  1. Modifying the .htaccess by adding the following code to the .htaccess file in the public_html folder of your hosting account. You will need to insert the following code block and make modifications as noted in the (#) comments
  2. You will need to change the two instances of to your domain, and the three instances of subdirectory to the folder where you installed your laravel app slash pubic/index.php. That is; if your app is hosted in “mylaravelapp” then subdirectory  will be “mylaravelapp/public/index.php”.
  3. And that’s it.

I would seriously advise against hosting your Laravel project on a shared hosting. If you need a staging environment to test your app, Heroku offers a free plan that supports hosting different applications including Laravel for free. I find Matt Stauffer post on Installing a Laravel app on Heroku interesting. You can give it a try.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *