安装 magento 后,css 和 js 文件出现 404 错误

I am getting 404 error for css and js files after I installed magento

我在 bluehost vps 主机上安装了 magento 2.4.2,但我得到的网站如图所示 1 我尝试了我在网上找到的所有解决方案,但没有一个对我有用。

我尝试过的解决方案:

1- 更改 pub/static 目录的权限。

2- 在 app/etc/di.xml 中,找到 virtualType name=”developerMaterialization” 部分及其名为 name=”view_preprocessed” 的项。我在 Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink.

中用复制更改了符号链接

3- php bin/magento setup:static-content:deploy -f 命令

4- RewriteEngine 开启,在 /pub/static/.htaccess 文件

5- 将签名静态文件设置为否(dev/static/sign 为 0)

我希望有人能提供帮助

您好@Silverwolf96,欢迎来到 Whosebug。

您可以做的事情很少try/check。

1.) 如果您文件的 URL 正确,请检查页面源代码。如果设置不正确,请按照步骤 2 中的说明手动设置它们。

2.) 转到 Store > Configuration > General > Web 并在 Base URLs & Base URLs (Secure) your URLs for static files 下设置 - 你可以手动设置这个URL需要设置为http://www.example.com/static/

3.) 您可以尝试在服务器

上移除pub/static/frontend

4.) 检查如果你 select Magento Luma 作为默认主题会发生什么