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

zlatiborac's avatar

Laravel on Hostgator shared server

Client is hosting 2 websites on 2 different servers with Hostgator. With the first installation everything went just fine and I just did the same steps with the second one. But when I enter URL of the site I just get Hostgator welcome message. but if I enter mysite.com/public it works. I tried changing the .htaccess file but every possible combination didn't worked. My laravel folder is outside public_html and I use symlink to point to /public folder (which works but only with /public trailing the URL). Symlink I used is the same I have been using for years

ln -s ~/laravel/public ~/public_html

So any help would be appreciated.

0 likes
10 replies
zlatiborac's avatar

I would like to do this as I did with the first project with no changes to the core files and .htaccess redirects if possible...

zlatiborac's avatar
zlatiborac
OP
Best Answer
Level 2

When replacing the original content of the .htaccess with this

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

the site comes back to life... Original was like this

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

so the first / was the problem

zlatiborac's avatar

Yes, but if someone would like to explain to me what is the difference between

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

and

RewriteRule ^(.*)$ public/$1 [L,R=301]

because that was the error that took me 5 hours of work, and I want to get to the bottom of this, and someone may find this answer which will save a lot of time for him/her.

cimrie's avatar

@zlatiborac what you just copied there is not what you said originally. You said the original was

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

The problem in either version you presented is that the htaccess rule you had was only sending everything after a ' / ' to the public folder, so your main page was still being directed to the default root directory in your shared hosting.

Taking the ' / ' out just directs everything in the url to the public folder, which is what you want.

Try using a tool like this (http://htaccess.madewithlove.be) and just trial and error. You will get a feel for how it all works and how the rules affect the requests.

1 like
Spanros's avatar

I have just been onto support at Hostgator. Forget trying to use a shared account. I have been spending days trying to get Larvel working on my account. They no longer support the latest version 6/7.

I am looking for a cheap server, can anyone recommend, while I am still learning/experimenting. (now 53!)

from the transcript:

C Actually, the latest version of Laravel are no longer supported by our Shared servers due to the huge requirement of server resources it needs just to run it. The contents of the website is not yet included. That is the reason why our admins advises Laravel users to use at least a VPS server to install it. 10:45 pm

S how much is vps? 10:52 pm C The cheapest is our Snappy 2000 at $29.95/mo 10:53 pm

S ouch.. no thanks 10:53 pm0

Please or to participate in this conversation.