Forum Moderators: phranque

Message Too Old, No Replies

The old https/http redirect question

A good solution?

         

BenSeb

2:44 pm on Oct 16, 2007 (gmt 0)

10+ Year Member



Hi

I've been trying to get this implemented for ages now

I originally posted here: [webmasterworld.com...]

then got directed here: [webmasterworld.com...]

but this solutions seems to be split between httpd.conf and htaccess so it not quite working

Has a solution that works well been found, maybe in a more recent post?

Thanks for your time

PS:

I have this at present:
RewriteCond %{SERVER_PORT} ^443$
RewriteCond $1!^(basket¦promotion¦dj) [NC,OR]
RewriteCond $1!\.(css¦gif¦jpe?g¦bmp¦js¦inc¦swf)$ [NC]
RewriteRule (.*) [test.domain.com...] [R=301,L]

This allows https in basket, but not /promotion/ or /dj/ (redirects to http)

[edited by: BenSeb at 2:47 pm (utc) on Oct. 16, 2007]

BenSeb

2:51 pm on Oct 16, 2007 (gmt 0)

10+ Year Member



Aha

Do you think this would work? Tried it and seems ok but I'm not too hot on htaccess so might have a few flaws?

RewriteCond %{SERVER_PORT} ^443$
#RewriteCond $1!^(basket¦promotion¦dj) [NC,OR]
RewriteCond $1!^basket
RewriteCond $1!^dj
RewriteCond $1!^ads
RewriteCond $1!^promotion
RewriteCond $1!\.(css¦gif¦jpe?g¦bmp¦js¦inc¦swf)$ [NC]
RewriteRule (.*) [test.domain.com...] [R=301,L]

jdMorgan

11:28 pm on Oct 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your first attempt would have worked if you had removed the [OR] flag from the first RewriteCond.

You want the redirect
if NOT (A or B or C)
AND
if NOT (D or E or F)

Adding the [OR] flag in there messes up the logic, and guarantees that the rule will always execute.

For more on this subject, do a search on "DeMorgan's Theorem."

Jim