Forum Moderators: phranque

Message Too Old, No Replies

rewriteCond doesn't seem to execute properly

         

fduchaussoy

3:23 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



RewriteEngine On
RewriteLog "./rewrite_ssl.log"
RewriteLogLevel 9
RewriteCond ${QUERY_STRING} ^.*method=showMainHome.*$
RewriteRule ^.*$ [%{SERVER_NAME}:6666%{REQUEST_URI}...] [R=301]

This is rule that I have within my ssl.conf listening on port 4443 (SSLEngine on). I want to redirect the user from HTTPS to HTTP (so once logged in, I move them back to a non secure environment). I use a DispatchAction (Struts) which has the following query parameter login.do?method=showMainHome. Now if I comment the rewriteCond, the rule is executed and goes to port 6666, however if I put back rewriteCond the query String never match my RegExp for unknown reasons.... I am lost! Can anyone help me on that one, am I doing something stupid? (I am kind of new to Apache btw)

Regards.
Francois

jdMorgan

5:10 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Francois,

Welcome to WebmasterWorld!

You need a % sign, not a $ sign, on server variables:


RewriteCo[b]nd %{QU[/b]ERY_STRING} method=showMainHome
RewriteRule .* http://%{SERVER_NAME}:6666%{REQUEST_URI} [R=301]

I also removed several redundant regex tokens.

Jim

fduchaussoy

5:22 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



Thanks for your really QUICK reply. I actually had %, I just copied wrongly (DOH!).
I got it working except that when it goes back to HTTP (from HTTPS) it is losing the JSessionId. Any idea? :(

jdMorgan

5:26 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the sessionID is a cookie, then it won't be valid for any domain except the one it was issued from if your client is not set to accept third-party cookies... And https may be considered as a different domain.

Jim

dcrombie

9:56 am on Aug 6, 2005 (gmt 0)



If you set the "domain" of the cookie to ".example.net" and the path to "/" then it will be available on both "http://www.example.net/ and "https://www.example.net/" (and http:// www2.example.net/).

;)

fduchaussoy

8:01 am on Aug 8, 2005 (gmt 0)

10+ Year Member



How/Where do you set the cookie domain, since it is generated from my JSP container (I use OC4J app server)?
thks for the replies so far!

fduchaussoy

8:54 am on Aug 9, 2005 (gmt 0)

10+ Year Member



We are using those ports: 7777 for http and 4443 for https, is that the reason why it is seen as 2 different domains then?
eg: domain.com:7777 and domain.com:4443

dcrombie

9:57 am on Aug 9, 2005 (gmt 0)



By default, a cookie will be readable on any port - as long as the domain and path match. You can restrict it to a single port, or a list of ports, by setting the 'port' attribute.

fduchaussoy

10:19 am on Aug 9, 2005 (gmt 0)

10+ Year Member



dcrombie, can you pls tell me which file in Apache I would need to change to set the port numbers?

dank u

dcrombie

10:37 am on Aug 9, 2005 (gmt 0)



Sorry, ik heb geen idee over JSP of OC4J. You need to talk to your hosting provider/tech support.