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

karateka's avatar

CSS and JS file not found after deploy

Hi. I deploy my project to shared hosting and all my controllers, models etc works great but I have problem with CSS and JS file becouse for I have 404 errors for this files. On XAMPP server style and script files works great. In my opinion I my opinion it may be problem with my .htaccess file but I don't know how I can change in this file. My .htaccess file: Options -MultiViews

RewriteEngine On

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

RewriteCond %{HTTP_HOST} ^(www.)?mypage.com$ [NC] RewriteCond %{HTTPS} on [OR] RewriteCond %{HTTP_HOST} ^www. [NC] RewriteRule ^ http://mypage.com%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]

0 likes
1 reply
jlrdw's avatar

Look at this folder structure

https://drive.google.com/file/d/0B1_PFw--3o74WHNmMFlkRklKRTg/view?usp=sharing

Even on xamp or whatever install laravel using this guide:

http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet/

Again in development and production use the guide, I recently used it for a shared host, the guide works 100% with zero problems.

Load your css using asset helper:

<link href="<?php echo asset('assets/css/dog/style.css'); ?>" rel="stylesheet">

Just correctly resolve your paths.

NOTE: My example laravel54up is "above" webroot, and laravel54 is under webroot (htdocs or www or public_html) depending on host.

Again develop this same way, with same folder structure.

Please or to participate in this conversation.