Simple Rewrite Question

Morning all.

I have a very simple request to clean up

I basically need to catch URI’s that end with “/” and if they do, append
index.htm to them. The upstream proxy doesn’t like to see “/”.

so a request:

http://xyz/

would be rewritten to:

http://xyz/index.htm

and so on …

http://xyz/mytest/http://xyz/mytest/index.htm

BUT http://xyz/mytest is to be untouched! Only if it has a / at the
end.
I want to proxy_pass these to the backend. I am struggling to get this
right, so any pointers/help would be appreciated

thanks

I think i blundered upon the solution myself:

    location ~* /$ {
            rewrite (.*) $1index.cfm;
            proxy_pass http://beta.yourli.st;
    }

    location / {
            proxy_pass http://beta.yourli.st;
    }

This does indeed do the trick; what i was missing the “~* /$” in the
location directive.

Is there a more efficient way of doing this?

Alan W. ha scritto:

so a request:
http://xyz/
would be rewritten to:
http://xyz/index.htm
and so on …
http://xyz/mytest/http://xyz/mytest/index.htm
BUT http://xyz/mytest is to be untouched! Only if it has a / at the end.

try this:
rewrite ^/(.*)/$ /$1/index.htm;

Daniele

On Fri, Jan 16, 2009 at 11:11:29AM +0000, Alan W. wrote:

This does indeed do the trick; what i was missing the “~* /$” in the
location directive.

Is there a more efficient way of doing this?

You may also try

     location / {
         proxy_pass http://beta.yourli.st;
     }

     location ~* /$ {
         proxy_pass 

http://beta.yourli.st${uri}index.cfm$is_args$args;
}

thank you that’s great