Forum Moderators: phranque
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.
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
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.