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

AmirHesam's avatar

My site is hacked

I uploaded a laravel project on a shared hosting with Cpanel and it was working at first but after few minutes it was redirecting to a spam site and a redirect code was added in .htaccess. I deleted all files and reupload them but it happened again and deleting the redirect code didn't work. How is get hacked and what's the solution to solve this my site url: owjedanesh.com

0 likes
3 replies
jlrdw's avatar

Just a guess, but you probably didn't correctly point to public as the document root.

Myself and others have showed many times here on the forum how to correctly setup laravel.

1 like
chilldsgn's avatar

I've used shared hosting with Laravel before and never got hacked (because of clients' hosting setup), so shared hosting is not inherently a problem, it's how you set up your Laravel application in cPanel.

You probably exposed your .env file to the public. You should put your application code OUTSIDE the public_html directory and in cPanel, point your site to the public directory.

There are plenty of useful articles on how to get shared hosting to work with Laravel, just Google it. Some hosting companies have a slightly different set up.

You can delete and reupload files as much as you want, but they've already got access to your hosting environment, sorry.

I'm not opening your hacked site, sorry :)

1 like

Please or to participate in this conversation.