如何将 Magento 2 与 openlitespeed(免费)网络服务器一起使用?

How to use Magento 2 with an openlitespeed (free) web server?

我正在尝试使用 OpenLiteServer 设置 Magento 2.3.0 服务器并不断遇到奇怪的重写规则错误:

这是 full list 个错误。

website 正常,但是 CSS 和 JS 无法加载所以有很多 404s

我在想我可能做错了什么,或者 OpenLiteSpeed 不支持 .htaccess 文件中的所有这些命令。

magento 2 安装只是一个基本的 magento 2.3.0 作曲家安装,没有添加任何东西,因此设置为 默认 模式。

文件权限看起来也不错,但请注意 pub/static/frontend/luma/en_US/ 目录中缺少文件:

有什么提示吗?

谢谢

假设网站在/magento2下,您需要在虚拟主机上插入重写,在重写部分,同时启用重写模块。

  RewriteRule ^/magento2/pub/static/version.+?/(.+)$ /magento2/pub/static/ [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule /magento2/pub/static/.* /magento2/pub/static.php?resource=[=10=] [L]
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
  RewriteRule .* - [L,R=405]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule .* /magento2/index.php [L]