On Sat, Jul 13, 2024 at 08:48:56PM +1000, Paul W. Rankin wrote:
> Hello,
> 
> I’m trying to get a basic URL rewrite working with httpd but, alas, it 
> seems broken.

It's not broken :-).

> 
> My goal:
> 
>       /~USER -> /htdocs/u/USER

root "/htdocs/u"
location match "/~(.*)" {
        request rewrite "/%1"
        }

> To debug this, in case the “~” character was throwing something off, I 
> simply tried to achieve:
> 
>       /u/USER -> /htdocs/u/USER

root "/htdocs/u"
location match "/u/(.*)" {
        request rewrite "/%1"
        }

> I’m aware this can be achieved with request strip, but this is for 
> purposes of demonstrating the bug.

It's not a bug :-)

Try accessing specific files such as:

http://example.com/~my_user/my_file

and it works.

You are probably expecting _auto indexing_, which doesn't happen for rewritten
requests.

Depending on your use case you might want to a couple of extra location match
directives such as this:

location match "/~(.*)/" {
        request rewrite "/%1/index.html"
        }
location match "/~(.*)$" {
        request rewrite "/%1/index.html"
        }

...which will redirect such requests to an index.html file.

Reply via email to