# MODX supports Friendly URLs via this .htaccess file. You must serve web # pages via Apache with mod_rewrite to use this functionality, and you must # change the file name from ht.access to .htaccess. # # Make sure RewriteBase points to the directory where you installed MODX. # E.g., "/modx" if your installation is in a "modx" subdirectory. # # You may choose to make your URLs non-case-sensitive by adding a NC directive # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC] RewriteEngine On RewriteBase / # Prevent rewrite the .well-known directory used by LetsEncrypt by rules below of this rule RewriteRule "^\.well-known/" - [L] # Prevent dot directories (hidden directories like .git) to be exposed to the public # Except for the .well-known directory used by LetsEncrypt a.o RewriteRule "/\.|^\.(?!well-known/)" - [F] # Rewrite www.example.com -> example.com -- used with SEO Strict URLs plugin #RewriteCond %{HTTP_HOST} . #RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC] #RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # # or for the opposite example.com -> www.example.com use the following # DO NOT USE BOTH # #RewriteCond %{HTTP_HOST} !^$ #RewriteCond %{HTTP_HOST} !^www\. [NC] #RewriteCond %{HTTP_HOST} (.+)$ #RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L] . # Force rewrite to https for every host #RewriteCond %{HTTPS} !=on [OR] #RewriteCond %{SERVER_PORT} !^443 #RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Redirect the manager to a specific domain - don't rename the ht.access file # in the manager folder to use this this rule #RewriteCond %{HTTP_HOST} !^example\.com$ [NC] #RewriteCond %{REQUEST_URI} ^/manager [NC] #RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] # The Friendly URLs part RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] # For servers that support output compression, you should pick up a bit of # speed by un-commenting the following lines. #php_flag zlib.output_compression On #php_value zlib.output_compression_level 5