Advertisement

08.27.2008 at 02:53AM PDT, ID: 23681328 | Points: 500
[x]
Attachment Details

Using mod_rewrite with WWW and HTTPS

Asked by bdichiara in Apache Web Server, PHP Scripting Language, Secure Socket Layer (SSL) & HTTPS

Tags:

I'm trying to get the server to point correctly no matter what combination of URL is entered, for example, all of the following should redirect to https://www....

mydomain.com
www.mydomain.com
https://mydomain.com
http://www.mydomain.com
mydomain.com/anything/blah.php
www.mydomain.com/something/check/
--- and so on ---

any of these should add www if not present and https if not present. The closest I can get is using this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
RewriteRule (.*) https://www.mydomain.com%{REQUEST_URI} [L]

Note in the 2nd rule i'm explicitly declaring "mydomain.com" to make sure the www is in there. this is because if I visit https://mydomain.com, it won't add the www. it seems to work if i go to mydomain.com and www.mydomain.com, but https://mydomain.com causes the "this certificate is invalid" message. How do I accomplish this?Start Free Trial
[+][-]08.27.2008 at 04:06AM PDT, ID: 22323283

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 04:30AM PDT, ID: 22323415

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 06:35AM PDT, ID: 22324579

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 06:44AM PDT, ID: 22324652

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 07:29AM PDT, ID: 22325134

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 08:38AM PDT, ID: 22326020

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 08:51AM PDT, ID: 22326190

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_EXPERT_20070906