Forum Moderators: phranque

Message Too Old, No Replies

https, http, domain.com, www.domain.com

redirect causes non-secure connection

         

webapp

10:43 am on Feb 7, 2005 (gmt 0)

10+ Year Member



I read a post on here that helped me resolve a Google duplicate content issue. I used the following:

RewriteCond %{HTTP_HOST}!^www.\domain\.com 
RewriteRule ^.*$ [domain.com%{REQUEST_URI}...] [R=301,L]

This 301-redirected all [domain.com...] requests to [domain.com....] Perfect.

But now, if a user goes to check out to a shared SSL connection (https://ssl.mywebhost.com/domain.com/etc/file.html), it gets redirected to the non-secure [domain.com...]

Is there a way to fix this problem? I'm guessing I have to include a rewrite condition but I don't know where to start since I'm quite inexperienced at this. Thanks in advance.

Caterham

1:58 pm on Feb 7, 2005 (gmt 0)

10+ Year Member



Hi,

just change the Condition to

# if host is http://domain.com
RewriteCond %{HTTP_HOST} ^domain\.com
# force external redirect and last rule
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

If you use a "catch all"-Condition like "do x if Host is NOT y", remember to check also if the HTTP-Host is not empty:

RewriteCond %{HTTP_HOST} !^$

Otherwise you might have a 301 redirect loop (e.g. for old http/1.0 requests, where the HTTP-Host is not available)

But if your ssl-domain calls [domain.com...] instead of [domain.com...] (via a Proxy-Request), you've to check, if the remote_addr is not the IP from the ssl host.

Bob

jdMorgan

8:15 pm on Feb 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or just check for port 443.

Jim

webapp

3:34 pm on Feb 8, 2005 (gmt 0)

10+ Year Member



Thanks for the help. However it doesn't seem to be working.

My shared ssl includes "domain.com" in the url so the rewrite rule includes my ssl domain.

My secure connection: [ssl.webhost.net...]
gets redirected to: [domain.com...]

How do I write a RewriteCond that excludes my ssl connection? I'm not sure how to check if the remote_addr is not the IP from the ssl host nor do I know how to check for ports. I've checked the apache documentation but conditional statements are not my forte.. Thanks again.