I have an SSL cert on a subdomain we have (secure), however if someone attempts to access the folder using this method:
http://www.domain.com/secure
or https://www.domain.com/secure
It shows the SSL error "ssl_error_bad_cert_domain" which is correct, so what I wanted to do was prevent anyone accessing the secure folder directly, instead forcing them to:
https://secure.domain.com
Which then ensures the SSL cert works correctly.
I am assuming this can be done using the开发者_如何学Go .htaccess file in the subdomain folder (which already forces it to use https), but I'm just not sure how to accomplish it.
Many thanks.
Update 1
Including current subdomains .htaccessRewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
You won't be able to redirect from https://www.domain.com/secure/
, because it will attempt to validate the certificate before it attempts any redirect. You'd need a valid certificate covering "www.domain.com" for that to work.
To cover http://www.domain.com/secure
, you can use the following.
Redirect 301 /secure/ https://secure.domain.com/
精彩评论