CPanel hosted Symfony website displays only HTML, fails to load the CSS and JS files

时光总嘲笑我的痴心妄想 提交于 2021-02-11 13:27:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!