Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

joakivmr's avatar

Only '/' root route works, my host claims it's laravel config

Hi everyone,

I'm in the process of putting my first Laravel app online, but have trouble with the routes when deploying. I have a shared hosting domain through Siteground, and due to the nature of things I have to put the Laravel app in a sub-directory. Basically I would like the structure to be; http://www.mydomainname.com/cloudburst/

I followed peoples advice to separate the public folder of my app (placed in my hosts "~/public_html" folder as "cloudburst"), and the rest of the code (stored "~/app_cloudburst/"). I updated both references in "index.php" to link to "/../../app_cloudburst/bootstrap/" etc and got the root website to load.

Now, the problem is that all my OTHER ROUTES (in routes/web.php) and links lead back to http://www.mydomainname.com/ instead of http://www.mydomainname.com/cloudburst/{route}!

Now, if I pass it through the index.php file it actually loads, like; http://mydomainname.com/cloudburst/index.php/images

I played around with the .htaccess file in my public "cloudburst" folder for hours yesterday, thinking the issue has got to be with this file. I then contacted my host asking for help, as I know (and understand) very little about .htaccess. They tested a few things, but the reply I got is now that they believe it's due to a config in Laravel - and not in the htaccess.

Here is the code from the .htaccess;

<IfModule mod_rewrite.c>
   <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

  <IfModule mod_rewrite.c>
  RewriteEngine On
    RewriteBase /cloudburst/
   # change above to your site i.e.,  RewriteBase /whatever/public/

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ /cloudburst/index.php [L]
</IfModule>


AddHandler application/x-httpd-php56 .php .php5 .php4 .php3

I also edited this value in Laravel (/app_cloudburst/config/app.php)

'url' => env('APP_URL', 'http://www.mydomainname.com/cloudburst')

I would be eternally grateful for any clues as to how to fix this! Is is actually a configuration in Laravel causing this? Am I on the right track thinking it's related to .htaccess? Could it be the .htaccess file for my other non-Laravel site causing this?

I see others have had similar issues, but none of edits that worked for them seems to help me.

0 likes
8 replies
Snapey's avatar

check your routes in web.php. do they all start with '\' ?

joakivmr's avatar

Hello Snapey! Thanks for your answer. Here is a small excerpt of my web.php with examples of some routes;

Route::get('/','PagesController@index');
Route::get('about', 'PagesController@about');
Route::get('help', 'PagesController@help');

Also images and other links are affected. There might be better ways to structure all routes and linkes than what I've done for this app, but all works seamlessly in local environment.

Snapey's avatar

@jlrdw thats more or less what the OP has done but it does not seem to be working

jlrdw's avatar

Have you tried various combinations of slashes with

RewriteBase /cloudburst/

And also in routes? Many times this is just a case of correctly resolving the paths, try various combinations of

../

You shouldn't have to modify the htaccess file except RewriteBase

willvincent's avatar

This is a 'duh' question that nobody's asked yet.. are you sure that the server is running apache, and that your htaccess file is being read?

If the server is running nginx, for example, nothing in the htaccess file will matter since nginx doesn't use them.

1 like
joakivmr's avatar

Finally managed to get it working! It appears that all my links were written simply as href="/nameofroute/". A simple switch to either "./nameofroute/" or what I assume is probably best practice(?); Laravel's URL attribute

<a href="{{ url('/about') }}">

did the trick.

In my mind I always assumed that if the .htaccess file was correctly configured, all relative links would append to the RewriteBase and not root domain if named as the subdirectory. I will have to read up on all this. It all worked in my localhost Apache, so I never thought much of it.

I would like to thank each and everyone for your help! I learned a LOT from your answers. Will look into nginx configuration, maybe that would've solved my problem straight away. Thing is; I had two very helpful people from Siteground trying to configure the .htaccess file, so I assumed they knew they were Apache files.

Hope all of you have a great day!

Please or to participate in this conversation.