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

web-chiru's avatar

I wanna make my laravel site live on hostgator shared hosting

Hi all, I have few queries related to making site live on hostgator shared hosting plan. Now i am running on my mac. Firstly i wanna set up local system for my site so that i can run my local app from project root directory, like http://localhost/my_laravel

so, right now i can run the site 2 way, 1 using php artisan serve, http://localhost:8000 2 http://localhost/my_laravel/public

so i don't want to use both above way and simply using some changes wanna run as http://localhost/my_laravel

i tried copying public content in root and did some htaccess changes but somehow i run home page but my other routing was not working which is working using above 2 method.

So, my first query is to resolve the issue of removing public folder from url and i wanna do same on live site so that i can run www.mydomain.com/ and not using public in url...

i am using mac os with MAMP on local system.

0 likes
28 replies
brendonaohanlon@gmail.com's avatar

Just a note though, you might (just did it today) want to upgrade the version of PHP being used depending on which version of Laravel you are using.

pdechery's avatar

Hi,

I'm having issues with this approach (the Medium link), which I've implemented just yesterday and it's working for the most part. BUT...

Routes misteriously don't work anymore, just a few ones and I can't tell the reason why.

For example, some links take me to the good address which has the following structure: http://decheryweb.com.br/prixphotoweb/galeria

Others take to this structure, which is wrong: http://decheryweb.com.br/concurso

If anyone's interested in help, my app resides now in this address (temporarily): http://decheryweb.com.br/prixphotoweb/

You can just click on the links on the red menu on the upper right and you'll see the problem.

Thanks.

btw, I'm currently doing some investigations and have noticed that if I run my local version right from the browser, without php artisan serve, like so:

http://localhost/prix-photo-web/public/

The same behavior happens, which is, routes stop working.

Some advice would be really helpful now.

OBS: Just a note, I can't run any php commands in my server, like php artisan whatever.

pdechery's avatar

Hi,

For anyone who might be interested, here's the solution I've found for the problem I've related above:

When in production, and when your server is shared, never code url's like that in your HTML:

<a href="path/to/your/app">My Link</a>

Instead, use this:

 <a href="{{ url('path/to/your/app' }}">My Link</a>

... and just let laravel resolve the correct path for you.

I know this is very basic, but it took me a while to get it, let alone some minutes of anxiety and frustration.

Cheers!

Snapey's avatar

@Hujjat

... and if I go to /technig/.env I see all of your private settings and have complete control over your website ?

This is a BAD approach

Hujjat's avatar

@snapey

I mostly delete the .env file and add the variable values directly in the config file.

What's your better solution or suggestion to do that?

Snapey's avatar

@Hujjat

I mostly delete the .env file and add the variable values directly in the config file.

Then you should put this in your tutorial since following your advice, sites can be badly hacked (try this: http://lmgtfy.com/?q=filetype%3Aenv+APP_ENV )

The best solution is that the content of the public folder is the only content accessible over the internet. Everything else is above the public folder.

1 like

Please or to participate in this conversation.