.htaccessmagento2magento-2.0litespeedmagento-2.3

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


I'm trying to setup Magento 2.3.0 server with OpenLiteServer and keep on bumping weird Rewrite rule errors:

LiteSpeed errors

Here's the full list of errors.

The website is working, but CSS and JS cannot be loaded so there are lot's of 404s

tyanabelle.com

I'm thinking that I may be doing something wrong, or that OpenLiteSpeed does not support all of those commands inside the .htaccess files.

The magento 2 installation is just a basic magento 2.3.0 composer installation without anything added to it, and thus is set to default mode.

The file permissions are looking good too, but note that files are missing from the pub/static/frontend/luma/en_US/ directory:

permissions

Any hints?

Thank you


Solution

  • Assuming that the website is under /magento2 you'll need to insert the rewrites on the virtual host, at the rewrites section, enable the rewrite module as well.

      RewriteRule ^/magento2/pub/static/version.+?/(.+)$ /magento2/pub/static/$1 [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteRule /magento2/pub/static/.* /magento2/pub/static.php?resource=$0 [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]