<IfModule mod_rewrite.c> RewriteEngine On ## turn off the Rewrite if in HTTPS Mode RewriteCond %{HTTPS} off ## exclude some URL from the Rewrite Rule RewriteCond %{REQUEST_URI} !/th/counterservice_order_receive\.php # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. # [NC] is a case-insensitive match # add www only not have www. RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule>