Results 1 to 7 of 7
-
12-09-2006, 12:44 AM #1Newbie
- Join Date
- Jan 2005
- Posts
- 12
Redirect .htaccess Question -- Please Advise
Hello WHT'ers,
Okay, here is the scenario--
I am trying to create a redirect with .htaccess so that if anyone goes to the following addresses (listed below) it will redirect them to https://www.domain.com
http://www.domain.com
http://domain.com
https://domain.com
Right now, using the code below, the redirect works with http://www.domain.com AND http://domain.com but NOT with https://domain.com.
So, what do I need to add/change in the .htaccess file so that https://domain.com redirects to https://www.domain.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.domain.com%{REQUEST_URI}
Thank you in advance for any help!
-
12-09-2006, 01:49 AM #2Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
You mean https://domain.com redirects to http://www.domain.com? If so use
RewriteCond %{SERVER_PORT} ^80$
to limit a rule to http and / or
RewriteCond %{SERVER_PORT} ^443$
for httpsChris
"Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter
-
12-09-2006, 01:52 AM #3Newbie
- Join Date
- Jan 2005
- Posts
- 12
Hello foobic,
I mean https://domain.com redirects to https://www.domain.com.
Thank you for your help!
-
12-09-2006, 02:02 AM #4Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
Sorry, didn't make myself very clear there... What I meant was:
When you say it doesn't work, do you mean that https://domain.com is now redirecting to http://www.domain.com? If so etc etc.
In short, use the server port to determine whether you're on an ssl connection and redirect accordingly.Chris
"Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter
-
12-09-2006, 02:16 AM #5Newbie
- Join Date
- Jan 2005
- Posts
- 12
I should have been more clear as well. The whole point of trying to get https://domain.com to redirect to https://www.domain.com is so that I don't get a "Security Error: Domain Name Mismatch" error since the certificate is for www.domain.com NOT domain.com. I hope that makes sense.
-
12-09-2006, 02:50 AM #6Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
In terms of the redirects, something like this should do what you want:
Code:RewriteCond %{HTTP_HOST} ^domain\.com$ RewriteCond %{SERVER_PORT} ^443$ RewriteRule (.*) https://www.domain.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain\.com$ RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
HTHChris
"Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter
-
12-09-2006, 04:02 PM #7Newbie
- Join Date
- Jan 2005
- Posts
- 12
Hello foobic,
Thank you for all your help! I really appreciate it!