You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Michy <di...@hotmail.com> on 2003/11/03 23:23:32 UTC

[users@httpd] mod_rewrite & %{HTTP:header}

Hi Users,

I have a problem with mod_rewrite. I would like to do a conditional rewrite
depending on the Content-Type of a document being processed. In the
documentation I found following:

There is the special format: %{HTTP:header} where header can be any HTTP
MIME-header name. This is looked-up from the HTTP request. Example:
%{HTTP:Proxy-Connection} is the value of the HTTP header
"Proxy-Connection:''.

And I tryed the RewriteCond on the HTTP header "Content-Type" as follow:

    RewriteCond %{HTTP:Content-Type} .*html.*

but it doesn't work!! In the log file I have only an empty 'input':

    RewriteCond: input='' pattern='.*html.*' => not-matched

What am I doing wrong?

Thanks for your help!!
Cheers,
Michele

---------------------------------------------------------------------
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 to https for password

Posted by Michy <di...@hotmail.com>.
> I would like to redirect the http traffic to https when I have to write a
> password (say via .htaccess)
>
> RewriteCond ???
> RewriteRule RewriteRule ^(.*) https://www.hostname.com$1 [R,L]
>
> Can someone help me?

I found this:

  RewriteCond %{HTTP:Authorization} ^.+
  RewriteRule ^(.*) https://%{HTTP_HOST}$1 [R,L]

but unfortunately %{HTTP:Authorization}is empty when the login windows
appear ;-((

Heeeelp!!

Cheers,
Michele
--
Michele Marcionelli - webmaster@math - Phone: +41 1 632 6193
Address: HG G 14 - Rämistrasse 101 - 8092 Zürich - Switzerland

---------------------------------------------------------------------
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


[users@httpd] redirect to https for password

Posted by Michy <di...@hotmail.com>.
Hi Users and Masters...

I would like to redirect the http traffic to https when I have to write a
password (say via .htaccess)

RewriteCond ???
RewriteRule RewriteRule ^(.*) https://www.hostname.com$1 [R,L]

Can someone help me?
Cheers,
Michele

--
Michele Marcionelli - webmaster@math - Phone: +41 1 632 6193
Address: HG G 14 - Rämistrasse 101 - 8092 Zürich - Switzerland

---------------------------------------------------------------------
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] mod_rewrite & %{HTTP:header}

Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 4 Nov 2003, Michy wrote:
> I want to apply the following rewrite rule to HTML (!!) documents only.
>
>     RewriteCond %{REQUEST_URI}       !.*/ns4.*
>     RewriteCond %{HTTP_USER_AGENT}   ^Mozilla/4\.7.*
>     RewriteRule ^(.*) http://www.hostname.com$1/ns4 [R,L]
>
> The problem is that my documents are generated by zope and they don't have a
> trailing ".html", so I have to find out some other way... like
> "Content-Type" or MIME Type...

This is a relatively difficult thing to do.  How is the server to know if
zope produced an html document until the document has actually been
produced?  And by then, it is obviously too late, since apache sends the
document as soon as it is produced.

In apache2 you could use an output filter that would buffer up the headers
until it saw content-type, then send a Location: if it was text/html.
This wouldn't be trivial.

I'd have to say, it probably makes more sense to do your user-agent stuff
internal to zope.

Joshua.

---------------------------------------------------------------------
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] mod_rewrite & %{HTTP:header}

Posted by Michy <di...@hotmail.com>.
Hi Joshua!!

> The %{HTTP:...} looks at client request headers.  I assume what you want
> is the server-generated response header Content-Type.  You can't get this,
> because mod_rewrite is run before the content-type of the file is
> determined.  (Theoretically, mod_rewrite could do a sub-request to get
> this info, but that feature has not been implimented.)

Ok... I see. That't why it did not work as expected by me ;-)

>
> Perhaps if you explained a little more what you are trying to accomplish,
> someone could suggest an alternative.

I want to apply the following rewrite rule to HTML (!!) documents only.

    RewriteCond %{REQUEST_URI}       !.*/ns4.*
    RewriteCond %{HTTP_USER_AGENT}   ^Mozilla/4\.7.*
    RewriteRule ^(.*) http://www.hostname.com$1/ns4 [R,L]

The problem is that my documents are generated by zope and they don't have a
trailing ".html", so I have to find out some other way... like
"Content-Type" or MIME Type...

Any Idea?

Thanks a lot,
Michele

---------------------------------------------------------------------
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


[users@httpd] How to Collect IP Addresses

Posted by Brian Menke <br...@innovtech.com>.
Hi Everyone, I know that there are existing log files (although I don't know
where) that collects ip addresses from request. I want to create a log file
that contains only ip addresses. I'm just wondering if there is some
existing tomcat way to do this instead of embedding it in my servlet code?

I thought maybe log4j, but that looks like it is for debugging purposes
only.

TIA!

-Brian


---------------------------------------------------------------------
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] mod_rewrite & %{HTTP:header}

Posted by Joshua Slive <jo...@slive.ca>.
On Mon, 3 Nov 2003, Michy wrote:
> I have a problem with mod_rewrite. I would like to do a conditional rewrite
> depending on the Content-Type of a document being processed. In the
> documentation I found following:
>
> There is the special format: %{HTTP:header} where header can be any HTTP
> MIME-header name. This is looked-up from the HTTP request. Example:
> %{HTTP:Proxy-Connection} is the value of the HTTP header
> "Proxy-Connection:''.
>
> And I tryed the RewriteCond on the HTTP header "Content-Type" as follow:
>
>     RewriteCond %{HTTP:Content-Type} .*html.*
>
> but it doesn't work!! In the log file I have only an empty 'input':
>
>     RewriteCond: input='' pattern='.*html.*' => not-matched
>
> What am I doing wrong?

The %{HTTP:...} looks at client request headers.  I assume what you want
is the server-generated response header Content-Type.  You can't get this,
because mod_rewrite is run before the content-type of the file is
determined.  (Theoretically, mod_rewrite could do a sub-request to get
this info, but that feature has not been implimented.)

Perhaps if you explained a little more what you are trying to accomplish,
someone could suggest an alternative.

Joshua.

---------------------------------------------------------------------
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