Redirect non-https requests to https server fixing double-login problem and ensuring that htpasswd authorization can only be entered using HTTPS:
Code:
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "google.com"
ErrorDocument 403 https://google.com
NOTE: This code fixes the issue of having to type in the username and password twice.
(more info about this)This will check to make sure that the connection IS using SSL, or it will fail.
It will also check to make sure that the HOST is tirmassagestone.com or it will fail
If it fails, it will issue a 403 "Forbidden" which will redirect to
https://google.comNOTE:There is a more thorough article at [url=http://www.askapache.com/htaccess/apache-ssl-in-htaccess-examples.html]AskApache.com
[/url]
Redirect everything attached to port 80:Code:
RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRule "^(.*)$" "https://%{SERVER_NAME}$1" [R=301,L]
Redirect particular URLs to a secure version:Code:
RewriteRule "^/normal/secure(/.*)" "https://%{HTTP_HOST}$1" [R=301,L]
Check to see whether the HTTPS environment variable is set:Code:
RewriteCond %{HTTPS} !=on
RewriteRule "^(/secure/.*)" "https://%{HTTP_HOST}$1" [R=301,L]
Use the Redirect directive to cause a URL to be served as HTTPS:Code:
Redirect / https://google.com/
Changing the scheme (SSL/noSSL) using relative URLs:Code:
RewriteEngine on
RewriteRule ^/(.*):SSL$ https://%{SERVER_NAME}/$1 [R,L]
RewriteRule ^/(.*):NOSSL$ http://%{SERVER_NAME}/$1 [R,L]
This lets you use hyperlinks of the form document.html:SSL