1 year ago

#349454

test-img

Trygve Aspenes

Apache LocationMatch: how to match again after internal redirect

I have a apache LocationMatch with two sets of RewriteCond and RewriteRule. If the second set hits I want to start the LoactionMatch over again.

In my apache2 ( Apache/2.4.41 (Ubuntu) mod_wsgi/4.9.0 Python/3.8 configured) config I have something like this:

<LocationMatch ^/incoming-request$>
    RewriteEngine On

    RewriteCond /tmp/test-file -f
    RewriteRule (.*) /some/service [QSA,L]

    RewriteCond /file-associated-with-the-request -f
    RewriteRule (.*) /myapp [L]

</LocationMatch>

Where myapp is a wsgi script which generates the /tmp/test-file and returns 301 redirect and Location: /incoming-request

/file-associated-with-the-request always exists.

So far so good.

If the /tmp/test-file does not exists then trigger the /myapp which then generates the /tmp/test-file. Then I want the LocationMatch to start over again so that the /some/service is triggered as /tmp/test-file exists after the first loop. This does not happen.

If I curl http://localhost/incoming-request I get the /tmp/test-file generated, and I get the return from /myapp. So if I want to get the return from /some/service I have to run the curl again.

Is there a way to kind of loop over again in the LocationMatch so I dont have to do my request twice?

apache

mod-rewrite

mod-wsgi

wsgi

0 Answers

Your Answer

Accepted video resources