right now, the following are redirected to https://mydomain.com: http://mydomain.com http://www.mydomain.com Code (markup): HOWEVER https://www.mydomain.com Code (markup): DOES NOT! here is my .htaccess Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} !^mydomain\.com [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,NC,L] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L] Code (markup): so how can i add a rule that will take https://www.mydomain.com and redirect it to that without the 'www'?
I added ( ) around the http_host and a ? making the content of the ( ) optional. The HTTP_HOST might not always be sent and that would create an infinite loop (because http_host never match). You can't redirect the request who do not send the http_host unfortunately. (http 1.1 request should send it, but not html 1.0 requests I also merged the 2 conditions together. As far as I know, when having a list of conditions, if any of these condition is met, the following rewriterule will apply. So you don't need to repeat that. I also added an https_host condition instead of http. I think that's how it must be used for the condition to work with https. Try this code and tell me how it goes. Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} !^(mydomain\.com)?$ [NC] RewriteCond %{HTTPS_HOST} !^(mydomain\.com)?$ [NC] RewriteCond %{SERVER_PORT} 80 [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,NC,L] Code (markup):
thanks for the help, but the HTTPS_HOST is not correct (i think). i had to add ORs to the rewrite conds too, but https://www.mydomain.com Code (markup): is still not redirecting. Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} !^(mydomain\.com)?$ [NC,OR] RewriteCond %{HTTPS_HOST} !^(mydomain\.com)?$ [NC,OR] RewriteCond %{SERVER_PORT} 80 [NC] RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,NC,L] Code (markup):
you don't need the OR. I tried it on my server and see https defaults to a completly different page than http (it auto redirects to /cgi-sys/defaultwebpage.cgi) with a message that it's a default website page (just like a brand new server without any files and server showing a default) My guess is that the http_host rule will have to be place on a completly different folder location for it to work. But I don't know where :/ As for https_host, it seems it's just not a valid attribute with the s. So just an http_host condition on .htaccess in that https folder, maybe? Sorry, I've never dealt with https. I can only suggest possible causes and solutions.