0

So I'm trying to get my server configured in a specific way so that anyone who visits http://www.subdomain.domain.com or https://www.subdomain.domain.com gets redirected to https:// without the www.

What Htaccess would I need to achieve this?

Tenatious
  • 109
  • 1
  • 7
  • http://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-as – TheCleaner Aug 29 '13 at 17:24

1 Answers1

0
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{HTTP_HOST} ^www\.subdomain\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://subdomain.domain.com/$1 [L,R=301]
GioMac
  • 4,444
  • 3
  • 24
  • 41
  • If I visit https://www.subdomain.com that isn't redirecting to https://subdomain.com – Tenatious Aug 29 '13 at 17:18
  • Then edit your question and clearly define what do you want. – GioMac Aug 29 '13 at 17:19
  • Pretty sure my question included the https:// part.... The example is https://www.clients.evaske.com/. I need that to link to https://clients.evaske.com as you can see if you click the link it throws up an SSL error. – Tenatious Aug 29 '13 at 17:20
  • 1
    You're going to get the SSL error with that cert unless you get a cert that matches *.clients.evaske.com. The rewrite only takes place AFTER the cert is presented. – TheCleaner Aug 29 '13 at 17:28
  • Is there no way to make it redirect before the certificate request? – Tenatious Aug 29 '13 at 17:29
  • Agree with @TheCleaner. It won't solve this particular problem... – GioMac Aug 29 '13 at 17:30