Forum Moderators: phranque

Message Too Old, No Replies

https pages not redirecting - please help!

http pages redirecting but https are not

         

precar

1:59 pm on Jun 25, 2009 (gmt 0)

10+ Year Member



Hi,

I'm having a problem redirecting https pages and would really appreciate your help.

I'm redirecting all pages from domainA.com to domainB.com. Right now regular pages redirect fine using:

RewriteCond %{HTTP_HOST} ^domainA\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domainA\.com$
RewriteRule ^(.*)$ [domainB.com...] [R=301,L]

I have tried the following solutions to redirect https pages but they have not worked:

RewriteCond %{HTTPS_HOST} ^domainA\.com$ [OR]
RewriteCond %{HTTPS_HOST} ^www\.domainA\.com$
RewriteRule ^(.*)$ [domainB.com...] [R=301,L]

-- and --

RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ [domainB.com...] [R=301,L]

The security certificate is only valid for domainB, so when I try to access [domainA.com...] in Firefox, I get the 'ssl_error_bad_cert_domain' error page. Ideally, the site should be redirected to [domainB.com...] before that error occurs.

Does anyone have any ideas or suggestions I could try? I have searched around for hours and was unable to find something specific to my situation.

Thanks in advance,
Precar.

jdMorgan

3:26 pm on Jun 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With a (slightly-optimized and more-robust) rule such as:

RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com
RewriteRule ^(.*)$ http://domainB.com/$1 [R=301,L]

the code does not care whether the request is made using HTTP or HTTPS. So the request will be redirected in either case *IF* the code is executed for that request. In order to be executed, the code must be in a directory location that is in the path between the DocumentRoot for the server and the file that is being requested -- Only .htaccess files in this path will be executed during the server's "directory walk."

So, I suspect that your code is not located in a location where it will be executed for HTTPS requests. Be aware that with some server configurations, the SSL and non-SSL "sites" are stored in separate directory structures and have different DocumentRoot directories.

Jim

precar

1:07 am on Jun 26, 2009 (gmt 0)

10+ Year Member



Thanks Jim, that helps a lot. I'll go to the system admin and ask them how their server is set up. I suspect you're right though, about the SSL and non-SSL pages being served up differently.

Precar.