Htaccess force ssl for a particlular domain

Hello forums,

How do I force SSL for a particular domain currently I have

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This is working, however I have several add on domains on my hosting and when I try to access the other add-on domains, the add on domains are also forced to use SSL .

I tried this:

RewriteCond %{HTTP_HOST} ^mydomain\\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\\.mydomain\\.org$
RewriteRule ^/?$ "https\\:\\/\\/www\\.mydomain\\.org\\/" [R=301,L]

But it is giving me an infinite loop.

Thanks.

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} exampledomain\.org$ [NC]
RewriteRule ^ https://www.examplemydomain.org%{REQUEST_URI} [R=301,L,NE]

sd,

That’s pretty close ( :tup: ) but I believe that {HTTPS} can only be null or “on” (without the quotes) so I check for not port 443 (SSL off). Your second line is SPOT ON! Your third, though, bothers me as the regex is simply the start anchor then the redirection - I’d recommend “.?” (without the quotes) as it will forct the match you’re looking for.

Is there a reason you’re using the No Escape flag? IMHO, that’s not needed.

To summarize, my code looks like:

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} exampledomain\\.org$ [NC]
RewriteRule .? https://www.examplemydomain.org%{REQUEST_URI} [R=301,L] 

Regards,

DK