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

SangminKim's avatar

Removing public but losing all the css & scripts url

Hi, I'm trying to remove /public from the url. I've been googling it and found lots of people saying

"Rename server.php in the root to index.php and copy the .htaccess from public to root."

Yes, this does display the website without having /public in the url... but it fails to load all the css & the scripts files I've stored in the public folder... how can I fix this issue?

The web is on a shared hosting.

Many thanks and happy new year!

0 likes
3 replies
moka's avatar

You need to set the Document Root on your web server to that public directory.

Snapey's avatar
Snapey
Best Answer
Level 122

if you play tricks to get around hosting the files correctly then things like the url and asset helpers won't work correctly because Laravel is confused about the public url structure.

your hosting provider should allow you to store files outside of the public space, and if they don't then move - there are too many providers to be stuck with one that forces you into a compromised install

so, if your provider says your webspace has a root folder and then a public_html folder within that with instructions to place your content in public_html then don't.

put all your laravel files and folders in the root folder and put all your public folder content in the public_html folder

1 like

Please or to participate in this conversation.