Forum Moderators: phranque

Message Too Old, No Replies

rewriting https <-> https and general redirect

         

cadillac

2:06 pm on Mar 12, 2004 (gmt 0)

10+ Year Member



Hello everyone,
I would like :
(1) to redirect all requests (except images¦css¦process) to /process/index.php,
(2) redirect to https if /checkout and
(3) redirect to http if not /checkout.
This is what I've done for (1) and (2), but when I add a rule for (3) it's not working anymore.
Any idea? Many thanks in advance.

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(checkout.*)$
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ [%{SERVER_NAME}%{REQUEST_URI}...] [L]
RewriteCond %{REQUEST_URI}!^/(css¦images¦process)/(.*)$
RewriteRule ^(.*)$ /process/index.php [L]

C.

closed

5:05 am on Mar 13, 2004 (gmt 0)

10+ Year Member



What code do you use for (3)?

cadillac

10:05 am on Mar 15, 2004 (gmt 0)

10+ Year Member



Thank you for your help. This is my current version.
The https to http works (rule 3 in my first message) but when I go to /checkout (rule 2) there is an immediate redirection to /process/index.php in http (which is rule 1). This script (process/index.php) handles all requests but should never be called directly. The only effective redirection (in the navigator location bar) should occur to switch between http/https and vice versa (sorry about my english...). I'm really not sure about the [L] or [R] instructions I need at this end of each rule.
Many thanks in advance.

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/checkout.*$
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ [%{SERVER_NAME}%{REQUEST_URI}...] [L]

RewriteCond %{REQUEST_URI}!^/checkout.*$
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^.*$ [%{SERVER_NAME}%{REQUEST_URI}...] [L]

RewriteCond %{REQUEST_URI}!^/(css¦images¦js¦process)/(.*)$
RewriteRule ^(.*)$ /process/index.php [L]

cadillac

4:19 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



If someone is interested, I finally solved the problem:

RewriteEngine on

RewriteCond %{REQUEST_URI}!^/(css¦images¦js¦process)/.*$
RewriteRule ^.*$ /process/index.php

RewriteCond %{REQUEST_URI} ^/checkout.*$
RewriteCond %{SERVER_PORT}!^443$
RewriteRule ^/.*$ [%{SERVER_NAME}%{REQUEST_URI}...] [R,L]

RewriteCond %{REQUEST_URI}!^/checkout.*$
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^/.*$ [%{SERVER_NAME}%{REQUEST_URI}...] [R,L]

dcrombie

11:01 am on Mar 16, 2004 (gmt 0)



Nice - but you can shorten it a bit by removing '.*$' from the end of your regexps - it's really not doing anything.

;)

cadillac

3:07 pm on Mar 16, 2004 (gmt 0)

10+ Year Member



That's even better. Thanks.