I have this .htaccess file, but I would like it to be done only when I am on the site.
Is there any way:
// if server_name looks like example.com to this // else dont run this bit RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} (auth|register|secure|payment|admin|trading_careers) RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(auth|register|secure|payment|admin|trading_careers) RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
I tried working with SetEnvIfNoCase and IfDefine without success. I donβt know if I can do what I want.
Thanks in advance.
EDIT (example for future readers):
// if https is off RewriteCond %{HTTPS} off // if server_name like example.com (case insensitive) OR RewriteCond %{SERVER_NAME} =example.com [NC,OR] // server_name like www.example.com (case insensitive)... RewriteCond %{SERVER_NAME} =www.example.com [NC] RewriteCond %{REQUEST_URI} (auth|register|secure|payment|admin|trading_careers) RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Thank you for your great help.
source share