问题
We tried uploading a Symfony5 website on Cpanel, and the website is only displaying the HTML part however the CSS and JS doesn't seem to load . It says "net::ERR_ABORTED 404 (Not Found)" or "Failed to load resource: the server responded with a status of 404 (Not Found)". We have two .htaccess files one, on the root of the project folder and another one inside the Public folder and the index.php on the public_html folder reads like below:
Index.php :
include dirname(__FILE__).'/<ProjectFileName>/public/index.php';
.htaccess found in the Root of the project :
<code>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$/public/$1 [L]
</IfModule>
.htaccess found inside the Public folder :
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
</IfModule>
</IfModule>
link CSS :
<link rel="stylesheet" type="text/css" href="{{ asset ('css/navbar.css')}}">
script JS :
<script src="{{ asset ('js/three.js') }}"></script>
<script src="{{ asset ('app/app_3D_responsive.js') }}"></script>
P.S : The website works perfectly well on localhost:8000!
Can someone please help!
Thank you in advance.
来源:https://stackoverflow.com/questions/63676327/cpanel-hosted-symfony-website-displays-only-html-fails-to-load-the-css-and-js-f