You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Krist van Besien <kr...@gmail.com> on 2007/12/01 23:22:50 UTC

Re: [users@httpd] Redirect HTTPS --> HTTP

On Nov 30, 2007 9:27 PM, Matt Bullock <mb...@root9.com> wrote:

> I see the issue with server_port =81 not being matched, but I have tried
> removing that directive, as well as changing it to !=81.  I don't really
> have any leads as to what to try next.

You are testing wether or not the server port is =81 or =80, but since
it is either 80 or 81 this never matches.

You need to realise that the RewriteCond ought to have been:
RewriteCond {SERVER_PORT} !81
(Since you don't need a = sign, I'm sorry I didn't find this out sooner)
You don't need this rewritecond however, as you allready take care of
sorting on port numbers by using virtual hosts.

However, I also see the following in your log:

domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (2) init rewrite
engine with requested uri /error/include/top.html
70.104.12.9 - - [30/Nov/2007:12:15:49 --0800] [www.
domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (3) applying
pattern '\.(html|php|css|js|jpg|gif|png|pdf|txt|swf|flv|wmv|wav|htm)$'
to uri '/error/include/top.html'
70.104.12.9 - - [30/Nov/2007:12:15:49 --0800] [www.
domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (4) RewriteCond:
input='!' pattern='(.*)' => matched
70.104.12.9 - - [30/Nov/2007:12:15:49 --0800] [www.
domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (1) pass through
/error/include/top.html

Do you have other rewrite rules?

Krist









-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirect HTTPS --> HTTP

Posted by Krist van Besien <kr...@gmail.com>.
On Dec 2, 2007 11:36 AM, Matt Bullock <mb...@root9.com> wrote:
> I need to test more but, on the http vhost if you don't specify the
> SERVER_PORT !=81, then it wont work.

You realise what you are doing, do you?
RewriteCond %{SERVER_PORT} !=81 is a condition that will always be
true, as %{SERVER_PORT} is never "=81".
So this conditionis entirely unneeded.

>             # Easy name for users' public profiles
>           RewriteCond ! (.*)

Same here, another condition that will always be true. See your log file.

What is it acutally you are trying to achieve? You wanted to redirect
https to http. That is easy and trivial. You also seem to want to
redirect some https under some circumstances back to http. My first
question is, why? Is there some pressing need why your users can't
continue using https that justifies you and me going to so much
trouble? (Basically I would just run everything over https and be done
with it. The whole internet ought to be encrypted anyway).

But if you really want this, let's see if we can help you.
What is it that you want to achieven? From your example I guess it is
the following.

requests to
http:/www.mydomain.com/scripts/vendor/membership.php
need to be forwarded to
https:/www.mydomain.com/scripts/vendor/membership.php

and requests to
https:/www.mydomain.com( something not scripts/vendor/membership.php)
need to be directed back to http.

You have two virtual hosts, on port 80 and port 81, and port 81 gets
all https traffic from your loadbalancer.

<VirtualHost *:80>

RewriteRule ^/scripts/vendor/membership\.php$
https://www.domain.com/scripts/vendor/membership\.php [R=301,L]

</VirtualHost>


<VirtualHost *:81>

RewriteCond $1    !/scripts/vendor/membership\.php
RewriteRule ^(.*)$   http://www.domain.com/$1 [R=301,L]

</VirtualHost>

Try this, and look in your rewritelog whether these rules are actually
considered. A typing error somewhere else in your config might really
mess things up.

Krist









-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Redirect HTTPS --> HTTP

Posted by Matt Bullock <mb...@root9.com>.
I need to test more but, on the http vhost if you don't specify the
SERVER_PORT !=81, then it wont work.

Besides the http/https rules, here are the only other rules that we are
using:

	    # Easy name for users' public profiles
          RewriteCond ! (.*)
          RewriteRule
\.(html|php|css|js|jpg|gif|png|pdf|txt|swf|flv|wmv|wav|htm)$ - [S=1]
          RewriteRule ^([^/]+) publicprofile.php?webprofileurl=$1
[L,QSA]

          # Force www if not present
          RewriteCond %{HTTP_HOST} ^domain\.com$
          RewriteRule ^.*$ http://www.domain.com%{REQUEST_URI} [R=301,L]

Thanks,

Matt

-----Original Message-----
From: Krist van Besien [mailto:krist.vanbesien@gmail.com] 
Sent: Saturday, December 01, 2007 2:23 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Redirect HTTPS --> HTTP

On Nov 30, 2007 9:27 PM, Matt Bullock <mb...@root9.com> wrote:

> I see the issue with server_port =81 not being matched, but I have
tried
> removing that directive, as well as changing it to !=81.  I don't
really
> have any leads as to what to try next.

You are testing wether or not the server port is =81 or =80, but since
it is either 80 or 81 this never matches.

You need to realise that the RewriteCond ought to have been:
RewriteCond {SERVER_PORT} !81
(Since you don't need a = sign, I'm sorry I didn't find this out sooner)
You don't need this rewritecond however, as you allready take care of
sorting on port numbers by using virtual hosts.

However, I also see the following in your log:

domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (2) init rewrite
engine with requested uri /error/include/top.html
70.104.12.9 - - [30/Nov/2007:12:15:49 --0800] [www.
domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (3) applying
pattern '\.(html|php|css|js|jpg|gif|png|pdf|txt|swf|flv|wmv|wav|htm)$'
to uri '/error/include/top.html'
70.104.12.9 - - [30/Nov/2007:12:15:49 --0800] [www.
domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (4) RewriteCond:
input='!' pattern='(.*)' => matched
70.104.12.9 - - [30/Nov/2007:12:15:49 --0800] [www.
domain.com/sid#55555585b900][rid#555555b7c6a8/subreq] (1) pass through
/error/include/top.html

Do you have other rewrite rules?

Krist









-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org