Require all denied RewriteEngine On RewriteRule (^|/)\.(?!well-known/) - [F,L] # Redirect non-www. to www. (except when on a subdomain) # RewriteCond %{HTTP_HOST} !^www\. # RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC] # RewriteRule ^ https://www.%{HTTP_HOST}/$1 [R=301,L] # Redirect HTTP to HTTPS # RewriteCond %{HTTPS} !=on # RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] # Remove any trailing slashes from non-directories using a redirect # RewriteCond %{REQUEST_FILENAME} !-d # RewriteCond %{REQUEST_URI} (.+)/$ # RewriteRule ^ %1 [R=301,L] # Rewrite /themes/{theme}/{file} to /themes/{theme}/public/{file} RewriteRule ^themes/([^/]+)/(?!public/)(.*)$ themes/$1/public/$2 [L] # Rewrite non-directory and non-file URLs to index.php # RewriteCond %{REQUEST_FILENAME} !-d # RewriteCond %{REQUEST_FILENAME} !-f # RewriteRule ^ index.php [L] # Allow direct access to theme files with URL format: /themes/{theme}/public/{file} RewriteRule ^themes/([^/]+)/public/(.*)$ themes/$1/public/$2 [L] # Allow direct access to uploaded files with URL format: /uploads/{filepath;,} RewriteRule ^uploads/.*\.(?:php[0-9]*|phtml|phar)(?:/|$) - [F,NC] RewriteRule ^uploads/(.*)$ uploads/$1 [L] # Rewrite all remaining requests to index.php # RewriteRule ^ index.php [L] FallbackResource /index.php