You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Toni Maatta <to...@borgship.net> on 2003/02/03 08:11:04 UTC

[users@httpd] rewrite problem

Hi,

How can I expand url http://www.company.com/ to
http://www.company.com/index.xxx 

I'd like to know whenever user request any .php/.pl/or so documents and
redirect all scripts to cgi-servers. But the problem is that I don't
know how can I match eg. .php, when there are no document name in url.

Any ideas?

-- toni

---------------------------------------------------------------------
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] rewrite problem

Posted by Toni Maatta <to...@borgship.net>.
Hi,

> http://httpd.apache.org/docs/misc/rewriteguide.html
> http://httpd.apache.org/docs/mod/mod_rewrite.html

I have read those already.. :)

> According to this document I think it is quite simple to solve your problem :
> RewriteEngine on
> RewriteRule (*.pl | *.php)  cgi-server/$1

Here's what happend:

httpd.conf:
RewriteRule (\.pl) http://cg1/$1 

rewrite-log:
x.x.x.x - - [03/Feb/2003:10:37:02 +0200]
[www.company.com/sid#809eb6c][rid#80bc8ac/initial] (3) applying pattern
'(\.pl)' to uri '/user/'

What the heck is that sid#809eb6c ?? Some id, but what.. 

> Also you should have a look for the environment variables such as REQUEST_URI

I'll try this soon..

-- toni

---------------------------------------------------------------------
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] rewrite problem

Posted by Jurgen <ap...@squarehosting.com>.
Hi,

so if you add index.php and index.cgi to DirectoryIndex mod_rewrite doesn't get apllied on the result?

Jurgen


On Mon, 3 Feb 2003 13:11:52 +0200
Toni Maatta <to...@borgship.net> wrote:

> Hi,
> 
> It's not that easy.. :) 
> 
> What I want, is that if url ends with / apache should check if the index
> file is .php or .cgi or something and if that match, it should redirect
> it. REQUEST_URI doesn't tell this information, so I don't know if it
> is possible at all .. 
> 
> On Mon, Feb 03, 2003 at 06:13:03AM -0500, Jurgen wrote:
> > Hi,
> > 
> > if you want to rewrite something ending in .php to the cgi server it should look like this:
> > 
> > RewriteCond %{REQUEST_URI} \.php$
> > RewriteRule  ^(.*)          http://cgi-server$1 [R]
> > 
> > Jurgen
> > 
> > 
> > On Mon, 3 Feb 2003 18:47:15 +0800
> > "Paul Muad`dib" <uz...@gmx.net> wrote:
> > 
> > > Cause you look for the request of /user/ and not /user/index.php
> > > 
> > > So you need to the condition to find an empty document /user/ to rewrite to
> > > a index.php for example so someth like that
> > > 
> > > RewriteCond %{REQUEST_URI}
> > > RewriteRule  ^*                http://cgi-server/index.php (or whatever) [R]
> > > 
> > > 
> > > 
> > > ----- Original Message -----
> > > From: "Toni Maatta" <to...@borgship.net>
> > > To: <us...@httpd.apache.org>
> > > Sent: Monday, February 03, 2003 6:34 PM
> > > Subject: Re: [users@httpd] rewrite problem
> > > 
> > > 
> > > > > Also you should have a look for the environment variables such as
> > > REQUEST_URI
> > > >
> > > > here's what happen, when I use REQUEST_URI:
> > > >
> > > > this is just a test, but you'll see what happens.
> > > > httpd.conf:
> > > > RewriteCond %{REQUEST_URI}     .php
> > > > RewriteRule  ^.*$                ${REQUEST_URI} [R]
> > > >
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (2) init rewrite
> > > > engine with requested uri /user/
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (3) applying pattern
> > > > '^.*$' to uri '/user/'
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (4) RewriteCond:
> > > > input='/user/' pattern='.php' => not-matched
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (1) pass through
> > > > /user/
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > > > engine with requested uri /user/index.html
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > > > /user/index.html
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > > > engine with requested uri /user/index.htm
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > > > /user/index.htm
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > > > engine with requested uri /user/index.shtml
> > > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > > > /user/index.shtml
> > > >
> > > > -- toni
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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
> > 
> > ---------------------------------------------------------------------
> > 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

---------------------------------------------------------------------
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] rewrite problem

Posted by Toni Maatta <to...@borgship.net>.
Hi,

It's not that easy.. :) 

What I want, is that if url ends with / apache should check if the index
file is .php or .cgi or something and if that match, it should redirect
it. REQUEST_URI doesn't tell this information, so I don't know if it
is possible at all .. 

On Mon, Feb 03, 2003 at 06:13:03AM -0500, Jurgen wrote:
> Hi,
> 
> if you want to rewrite something ending in .php to the cgi server it should look like this:
> 
> RewriteCond %{REQUEST_URI} \.php$
> RewriteRule  ^(.*)          http://cgi-server$1 [R]
> 
> Jurgen
> 
> 
> On Mon, 3 Feb 2003 18:47:15 +0800
> "Paul Muad`dib" <uz...@gmx.net> wrote:
> 
> > Cause you look for the request of /user/ and not /user/index.php
> > 
> > So you need to the condition to find an empty document /user/ to rewrite to
> > a index.php for example so someth like that
> > 
> > RewriteCond %{REQUEST_URI}
> > RewriteRule  ^*                http://cgi-server/index.php (or whatever) [R]
> > 
> > 
> > 
> > ----- Original Message -----
> > From: "Toni Maatta" <to...@borgship.net>
> > To: <us...@httpd.apache.org>
> > Sent: Monday, February 03, 2003 6:34 PM
> > Subject: Re: [users@httpd] rewrite problem
> > 
> > 
> > > > Also you should have a look for the environment variables such as
> > REQUEST_URI
> > >
> > > here's what happen, when I use REQUEST_URI:
> > >
> > > this is just a test, but you'll see what happens.
> > > httpd.conf:
> > > RewriteCond %{REQUEST_URI}     .php
> > > RewriteRule  ^.*$                ${REQUEST_URI} [R]
> > >
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (2) init rewrite
> > > engine with requested uri /user/
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (3) applying pattern
> > > '^.*$' to uri '/user/'
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (4) RewriteCond:
> > > input='/user/' pattern='.php' => not-matched
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (1) pass through
> > > /user/
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > > engine with requested uri /user/index.html
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > > /user/index.html
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > > engine with requested uri /user/index.htm
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > > /user/index.htm
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > > engine with requested uri /user/index.shtml
> > > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > > /user/index.shtml
> > >
> > > -- toni
> > >
> > > ---------------------------------------------------------------------
> > > 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
> 
> ---------------------------------------------------------------------
> 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


Re: [users@httpd] rewrite problem

Posted by Jurgen <ap...@squarehosting.com>.
Hi,

if you want to rewrite something ending in .php to the cgi server it should look like this:

RewriteCond %{REQUEST_URI} \.php$
RewriteRule  ^(.*)          http://cgi-server$1 [R]

Jurgen


On Mon, 3 Feb 2003 18:47:15 +0800
"Paul Muad`dib" <uz...@gmx.net> wrote:

> Cause you look for the request of /user/ and not /user/index.php
> 
> So you need to the condition to find an empty document /user/ to rewrite to
> a index.php for example so someth like that
> 
> RewriteCond %{REQUEST_URI}
> RewriteRule  ^*                http://cgi-server/index.php (or whatever) [R]
> 
> 
> 
> ----- Original Message -----
> From: "Toni Maatta" <to...@borgship.net>
> To: <us...@httpd.apache.org>
> Sent: Monday, February 03, 2003 6:34 PM
> Subject: Re: [users@httpd] rewrite problem
> 
> 
> > > Also you should have a look for the environment variables such as
> REQUEST_URI
> >
> > here's what happen, when I use REQUEST_URI:
> >
> > this is just a test, but you'll see what happens.
> > httpd.conf:
> > RewriteCond %{REQUEST_URI}     .php
> > RewriteRule  ^.*$                ${REQUEST_URI} [R]
> >
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (2) init rewrite
> > engine with requested uri /user/
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (3) applying pattern
> > '^.*$' to uri '/user/'
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (4) RewriteCond:
> > input='/user/' pattern='.php' => not-matched
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80bca2c/initial] (1) pass through
> > /user/
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > engine with requested uri /user/index.html
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > /user/index.html
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > engine with requested uri /user/index.htm
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > /user/index.htm
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> > engine with requested uri /user/index.shtml
> > x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> > [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> > /user/index.shtml
> >
> > -- toni
> >
> > ---------------------------------------------------------------------
> > 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

---------------------------------------------------------------------
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] rewrite problem

Posted by Paul Muad`dib <uz...@gmx.net>.
Cause you look for the request of /user/ and not /user/index.php

So you need to the condition to find an empty document /user/ to rewrite to
a index.php for example so someth like that

RewriteCond %{REQUEST_URI}
RewriteRule  ^*                http://cgi-server/index.php (or whatever) [R]



----- Original Message -----
From: "Toni Maatta" <to...@borgship.net>
To: <us...@httpd.apache.org>
Sent: Monday, February 03, 2003 6:34 PM
Subject: Re: [users@httpd] rewrite problem


> > Also you should have a look for the environment variables such as
REQUEST_URI
>
> here's what happen, when I use REQUEST_URI:
>
> this is just a test, but you'll see what happens.
> httpd.conf:
> RewriteCond %{REQUEST_URI}     .php
> RewriteRule  ^.*$                ${REQUEST_URI} [R]
>
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80bca2c/initial] (2) init rewrite
> engine with requested uri /user/
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80bca2c/initial] (3) applying pattern
> '^.*$' to uri '/user/'
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80bca2c/initial] (4) RewriteCond:
> input='/user/' pattern='.php' => not-matched
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80bca2c/initial] (1) pass through
> /user/
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> engine with requested uri /user/index.html
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> /user/index.html
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> engine with requested uri /user/index.htm
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> /user/index.htm
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
> engine with requested uri /user/index.shtml
> x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
> [www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
> /user/index.shtml
>
> -- toni
>
> ---------------------------------------------------------------------
> 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


Re: [users@httpd] rewrite problem

Posted by Toni Maatta <to...@borgship.net>.
> Also you should have a look for the environment variables such as REQUEST_URI

here's what happen, when I use REQUEST_URI:

this is just a test, but you'll see what happens.
httpd.conf:
RewriteCond %{REQUEST_URI}     .php
RewriteRule  ^.*$                ${REQUEST_URI} [R]

x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80bca2c/initial] (2) init rewrite
engine with requested uri /user/
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80bca2c/initial] (3) applying pattern
'^.*$' to uri '/user/'
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80bca2c/initial] (4) RewriteCond:
input='/user/' pattern='.php' => not-matched
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80bca2c/initial] (1) pass through
/user/
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
engine with requested uri /user/index.html
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
/user/index.html
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
engine with requested uri /user/index.htm
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
/user/index.htm
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80c0e44/subreq] (2) init rewrite
engine with requested uri /user/index.shtml
x.x.x.x - - [03/Feb/2003:11:33:32 +0200]
[www.company.com/sid#809eb6c][rid#80c0e44/subreq] (1) pass through
/user/index.shtml

-- toni

---------------------------------------------------------------------
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] rewrite problem

Posted by Paul Muad`dib <uz...@gmx.net>.
Hi Toni,

after studying a bit cause such problems are of interest for me. I found a very interesting reference : 
http://httpd.apache.org/docs/misc/rewriteguide.html
http://httpd.apache.org/docs/mod/mod_rewrite.html

According to this document I think it is quite simple to solve your problem :

RewriteEngine on
RewriteRule (*.pl | *.php)  cgi-server/$1

Also you should have a look for the environment variables such as REQUEST_URI

Paul


  ----- Original Message ----- 
  From: Toni Maatta 
  To: users@httpd.apache.org 
  Sent: Monday, February 03, 2003 3:55 PM
  Subject: Re: [users@httpd] rewrite problem


  Hi Paul,

  Well.. You understood me wrong, so.. :)

  Let's say I have two machines; www-server, which handles all .html files
  only and cgi-server, which handles all cgi-scripts.

  So I want that www-server handles .html files and cgi-server
  .cgi/.pl/whatever files.

  Now when user uses url http://www.company.com/ I'd like to know what
  document user is trying to access. if it's a index.html I want that my
  www-server handles that request and if it eg. index.cgi I want that my
  www-server rewrites it and redirect it to cgi-server. 

  So I'd like to get document name every time and rewrite it if
  neccessary. I have tried some options, but I haven't been able to get it
  work. in rewrite log there's no document name in input field, when
  accessing "main page".

  I hope you understand my problem now.. ;)

  On Mon, Feb 03, 2003 at 03:45:19PM +0800, Paul Muad`dib wrote:
  > Hi Toni,
  > 
  > first I don't really understand what you want but maybe this will help you :
  > 
  > 1) you don't need to expand an URL
  >  Apache automatically does it for you whenever there is a index.html in the
  > document folder it will autmatically show it.
  >  If you want to have to show an index.php instead of index.html you need to
  > set that in your httpd.conf :
  >  DirectoryIndex index.php index.html
  >  --> this means apache first will try to call index.php if it doesn't exist
  > it will show index.html
  > 
  > 2) Redirecting pl/php scripts
  > There is an existing Directive for it ( you can find in the documentation
  > for further information ), I think you look for that :
  > AddHandler perl .pl
  > AddHandler php .php
  > Of course this means you need to include the according modules and also the
  > ScriptAlias directive but you can find enough information about that in the
  > www and also on the documentation on http://httpd.apache.org/docs-2.0.
  > 
  > I hope it was helpful and btw RTFM ;-)
  > 
  > Paul
  > 
  > 
  > ----- Original Message -----
  > From: Toni Maatta
  > To: users@httpd.apache.org
  > Sent: Monday, February 03, 2003 3:11 PM
  > Subject: [users@httpd] rewrite problem
  > 
  > 
  > Hi,
  > 
  > How can I expand url http://www.company.com/ to
  > http://www.company.com/index.xxx
  > 
  > I'd like to know whenever user request any .php/.pl/or so documents and
  > redirect all scripts to cgi-servers. But the problem is that I don't
  > know how can I match eg. .php, when there are no document name in url.
  > 
  > Any ideas?
  > 
  > -- toni
  > 
  > ---------------------------------------------------------------------
  > 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
  > 

  ---------------------------------------------------------------------
  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] rewrite problem

Posted by Paul Muad`dib <uz...@gmx.net>.
Hi Toni,

ok now it is more clear ....

hmm but still you could use the ScriptAlias directive to solve this problem ( I think/assume )
I would do the following, maybe it is not the best solution, but at least a workaround :

Add to your httpd.conf something like that                  RedirectMatch (\.pl | \.php)  http://cgi-server.com/$1  
I don't know if hte regex is right you need to study it but I know you can someretrieve the requested pl/php script with $... 
Info on that directive can be found here --> http://httpd.apache.org/docs-2.0/mod/mod_alias.html#redirectmatch

Also you could possibly set the DirectoryIndex to index.pl by default and then do the rewriting through the "referrer-url"

I hope this time it was more helpful and please let me know if it worked like that ...

Paul

----- Original Message ----- 
  From: Toni Maatta 
  To: users@httpd.apache.org 
  Sent: Monday, February 03, 2003 3:55 PM
  Subject: Re: [users@httpd] rewrite problem


  Hi Paul,

  Well.. You understood me wrong, so.. :)

  Let's say I have two machines; www-server, which handles all .html files
  only and cgi-server, which handles all cgi-scripts.

  So I want that www-server handles .html files and cgi-server
  .cgi/.pl/whatever files.

  Now when user uses url http://www.company.com/ I'd like to know what
  document user is trying to access. if it's a index.html I want that my
  www-server handles that request and if it eg. index.cgi I want that my
  www-server rewrites it and redirect it to cgi-server. 

  So I'd like to get document name every time and rewrite it if
  neccessary. I have tried some options, but I haven't been able to get it
  work. in rewrite log there's no document name in input field, when
  accessing "main page".

  I hope you understand my problem now.. ;)

  On Mon, Feb 03, 2003 at 03:45:19PM +0800, Paul Muad`dib wrote:
  > Hi Toni,
  > 
  > first I don't really understand what you want but maybe this will help you :
  > 
  > 1) you don't need to expand an URL
  >  Apache automatically does it for you whenever there is a index.html in the
  > document folder it will autmatically show it.
  >  If you want to have to show an index.php instead of index.html you need to
  > set that in your httpd.conf :
  >  DirectoryIndex index.php index.html
  >  --> this means apache first will try to call index.php if it doesn't exist
  > it will show index.html
  > 
  > 2) Redirecting pl/php scripts
  > There is an existing Directive for it ( you can find in the documentation
  > for further information ), I think you look for that :
  > AddHandler perl .pl
  > AddHandler php .php
  > Of course this means you need to include the according modules and also the
  > ScriptAlias directive but you can find enough information about that in the
  > www and also on the documentation on http://httpd.apache.org/docs-2.0.
  > 
  > I hope it was helpful and btw RTFM ;-)
  > 
  > Paul
  > 
  > 
  > ----- Original Message -----
  > From: Toni Maatta
  > To: users@httpd.apache.org
  > Sent: Monday, February 03, 2003 3:11 PM
  > Subject: [users@httpd] rewrite problem
  > 
  > 
  > Hi,
  > 
  > How can I expand url http://www.company.com/ to
  > http://www.company.com/index.xxx
  > 
  > I'd like to know whenever user request any .php/.pl/or so documents and
  > redirect all scripts to cgi-servers. But the problem is that I don't
  > know how can I match eg. .php, when there are no document name in url.
  > 
  > Any ideas?
  > 
  > -- toni
  > 
  > ---------------------------------------------------------------------
  > 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
  > 

  ---------------------------------------------------------------------
  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] rewrite problem

Posted by Toni Maatta <to...@borgship.net>.
Hi Paul,

Well.. You understood me wrong, so.. :)

Let's say I have two machines; www-server, which handles all .html files
only and cgi-server, which handles all cgi-scripts.

So I want that www-server handles .html files and cgi-server
.cgi/.pl/whatever files.

Now when user uses url http://www.company.com/ I'd like to know what
document user is trying to access. if it's a index.html I want that my
www-server handles that request and if it eg. index.cgi I want that my
www-server rewrites it and redirect it to cgi-server. 

So I'd like to get document name every time and rewrite it if
neccessary. I have tried some options, but I haven't been able to get it
work. in rewrite log there's no document name in input field, when
accessing "main page".

I hope you understand my problem now.. ;)

On Mon, Feb 03, 2003 at 03:45:19PM +0800, Paul Muad`dib wrote:
> Hi Toni,
> 
> first I don't really understand what you want but maybe this will help you :
> 
> 1) you don't need to expand an URL
>  Apache automatically does it for you whenever there is a index.html in the
> document folder it will autmatically show it.
>  If you want to have to show an index.php instead of index.html you need to
> set that in your httpd.conf :
>  DirectoryIndex index.php index.html
>  --> this means apache first will try to call index.php if it doesn't exist
> it will show index.html
> 
> 2) Redirecting pl/php scripts
> There is an existing Directive for it ( you can find in the documentation
> for further information ), I think you look for that :
> AddHandler perl .pl
> AddHandler php .php
> Of course this means you need to include the according modules and also the
> ScriptAlias directive but you can find enough information about that in the
> www and also on the documentation on http://httpd.apache.org/docs-2.0.
> 
> I hope it was helpful and btw RTFM ;-)
> 
> Paul
> 
> 
> ----- Original Message -----
> From: Toni Maatta
> To: users@httpd.apache.org
> Sent: Monday, February 03, 2003 3:11 PM
> Subject: [users@httpd] rewrite problem
> 
> 
> Hi,
> 
> How can I expand url http://www.company.com/ to
> http://www.company.com/index.xxx
> 
> I'd like to know whenever user request any .php/.pl/or so documents and
> redirect all scripts to cgi-servers. But the problem is that I don't
> know how can I match eg. .php, when there are no document name in url.
> 
> Any ideas?
> 
> -- toni
> 
> ---------------------------------------------------------------------
> 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
> 

---------------------------------------------------------------------
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] rewrite problem

Posted by Paul Muad`dib <uz...@gmx.net>.
Hi Toni,

first I don't really understand what you want but maybe this will help you :

1) you don't need to expand an URL
 Apache automatically does it for you whenever there is a index.html in the
document folder it will autmatically show it.
 If you want to have to show an index.php instead of index.html you need to
set that in your httpd.conf :
 DirectoryIndex index.php index.html
 --> this means apache first will try to call index.php if it doesn't exist
it will show index.html

2) Redirecting pl/php scripts
There is an existing Directive for it ( you can find in the documentation
for further information ), I think you look for that :
AddHandler perl .pl
AddHandler php .php
Of course this means you need to include the according modules and also the
ScriptAlias directive but you can find enough information about that in the
www and also on the documentation on http://httpd.apache.org/docs-2.0.

I hope it was helpful and btw RTFM ;-)

Paul


----- Original Message -----
From: Toni Maatta
To: users@httpd.apache.org
Sent: Monday, February 03, 2003 3:11 PM
Subject: [users@httpd] rewrite problem


Hi,

How can I expand url http://www.company.com/ to
http://www.company.com/index.xxx

I'd like to know whenever user request any .php/.pl/or so documents and
redirect all scripts to cgi-servers. But the problem is that I don't
know how can I match eg. .php, when there are no document name in url.

Any ideas?

-- toni

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


Re: [users@httpd] rewrite problem

Posted by Jurgen <ap...@squarehosting.com>.
Hi,

it is really not expanding. but if you run the scripts on aother server you have 2 possibilities. Either you connect by proxy or you redirect the browser.
If you want this to work outside the ScriptAlias directories you will need mod_rewrite.

Jurgen


On Mon, 3 Feb 2003 09:11:04 +0200
Toni Maatta <to...@borgship.net> wrote:

> Hi,
> 
> How can I expand url http://www.company.com/ to
> http://www.company.com/index.xxx 
> 
> I'd like to know whenever user request any .php/.pl/or so documents and
> redirect all scripts to cgi-servers. But the problem is that I don't
> know how can I match eg. .php, when there are no document name in url.
> 
> Any ideas?
> 
> -- toni
> 
> ---------------------------------------------------------------------
> 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