RewriteEngine On
# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend)/web/ - [L]
# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^backend(/(.*))?$ backend/web/$2 [S=1,L]
RewriteCond %{REQUEST_URI} !^/css
RewriteCond %{REQUEST_URI} !^/js
RewriteCond %{REQUEST_URI} /plugins
RewriteRule /plugins(.*) /plugins$1 [S=1]
# handle the case of frontend
RewriteCond %{REQUEST_URI} !^/plugins
RewriteRule .* frontend/web/$0
# Uncomment the following, if you want speaking URL
# RewriteCond %{REQUEST_URI} !^/plugins
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^([^/]+/web)/.*$ $1/index.php