Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Below is some code I added to my .htaccess code how can I add certain pages to be re-directed to https? (such as login.php & login.html)

Also, if the user types in www. they get a "untrusted connection" as the SSL is only valid without the www. How could I fix this?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /login.html
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
share|improve this question
You might want to split those into separate questions. – womble Nov 17 '09 at 21:03

1) You can always explicitly force redirects using the apache RedirectMatch statements:

RedirectMatch ^/login.html$ https://myhostname/login.html
RedirectMatch ^/logout.html$ https://myhostname/logout.html

2) The SSL problem goes away if you explicitly direct traffic to the proper version of the hostname (i.e. get them in the habit of using one format for the url). Another option is to use an SSL wildcard certificate if you want to service multiple hostnames with a single SSL instance.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.