You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Thomas -Balu- Walter <tw...@itreff.de> on 2002/07/28 18:13:02 UTC

AliasMatch / minimal match?

Hello experts,

I am stuck in setting up a regex to be used in the AliasMatch-directive
in Apache.

I want to make it possible to access some of my virtual webspaces even
if Apache was not yet configured or DNS-update takes too long :)

My virtual webspaces can be found in a directory structure like

/home/vwww/example.com/host/htdocs/

I wanted to make it possible to call that in a browser using:

http://localhost/vwww/host.example.com/

To do so, I've tried to set up a directive like:

AliasMatch ^/vwww/(.*)\.(.*)/(.*)$ /home/vwww/$2/$1/htdocs/$3
                             ^^^^ path $3
                        ^^^^ example.com $2
                  ^^^^ host $1

But since the regexp matches the longest possible match. I get the
following matches:

        $1 = host.example
        $2 = com

and not my needed result:

        $1 = host
        $2 = example.com

I've tried to make the first (.*) a (.*?) to get minimal matching like
it is supported by perl(?), but Apache does not seem to support it? At
least it tells me that it can not compile the regexp while trying to
start it.

Any ideas or suggestions what regexp I am supposed to use?

     Balu

PS: Same problem happens with the path:
http://localhost/vwww/www.example.com/some/path/index.html

gives me
        $1 = www.example
        $2 = com/some/path
        $3 = index.html
-- 
Windows is something like fast-food: 
It's finished in no time, but you don't get a full-filled feeling, and 
you can start again.                      - Bas Lijten (Holland) in #lfs

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: AliasMatch / minimal match?

Posted by Thomas -Balu- Walter <tw...@itreff.de>.
+ Joshua Slive <jo...@slive.ca> [28.07.02 18:35]:
> On Sun, 28 Jul 2002, Thomas -Balu- Walter wrote:
> > But since the regexp matches the longest possible match
> 
> Here's the trick:
> 
> AliasMatch ^/vwww/([^.]*)\.([^/]*)/(.*)$ /home/vwww/$2/$1/htdocs/$3
> 
> [^.] means any character except the period.
> 
> I'm not sure if that will do exactly what you want, but it should give you
> the idea.

Thanks that was exactly the impulse that was missing - I'd call it
"inversing the regexp", because you look for "anything but" and not
"character" :)

     Balu

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: AliasMatch / minimal match?

Posted by Joshua Slive <jo...@slive.ca>.
On Sun, 28 Jul 2002, Thomas -Balu- Walter wrote:
> My virtual webspaces can be found in a directory structure like
>
> /home/vwww/example.com/host/htdocs/
>
> I wanted to make it possible to call that in a browser using:
>
> http://localhost/vwww/host.example.com/
>
> To do so, I've tried to set up a directive like:
>
> AliasMatch ^/vwww/(.*)\.(.*)/(.*)$ /home/vwww/$2/$1/htdocs/$3
>                              ^^^^ path $3
>                         ^^^^ example.com $2
>                   ^^^^ host $1
>
> But since the regexp matches the longest possible match

Here's the trick:

AliasMatch ^/vwww/([^.]*)\.([^/]*)/(.*)$ /home/vwww/$2/$1/htdocs/$3

[^.] means any character except the period.

I'm not sure if that will do exactly what you want, but it should give you
the idea.

Joshua.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org