You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ryan <rp...@willconsult.com> on 2002/02/27 21:06:20 UTC

Alias works fine, AliasMatch breaks ??

I have an alias setup, like
Alias /foo  /home/WWW-data/349

I now need to be a little more flexible on how people reach /foo, so I'm 
trying to use AliasMatch.  But even without putting any regexp's in there, 
AliasMatch doesn't work.  I'm using
AliasMatch /foo  /home/WWW-data/349

When I try to pull up /foo, I get the page thats usually served from my 
default virtual host (the fist one listed in httpd.conf). Very 
strange.  Any ideas?  The docs say AliasMatch works just like Alias, except 
it allows regular expressions.  But its not working like that for me.

Thanks,
-Ryan


---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Alias works fine, AliasMatch breaks ??

Posted by Owen Boyle <ob...@bourse.ch>.
Ryan wrote:
> 
>  > AliasMatch ^/foo(.*)  /home/WWW-data/349$1
> 
> Thanks Owen, that worked.  But if someone puts in /foo5/, that ends up
> getting aliased to /home/WWW-data/3495/, which is someone else's
> directory.  I tried to anchor it to the end of the string with ^/foo/(*.)
> but that didn't work.  Is it possible to make it match only match /foo/ ?

I take it you really mean (look again at what you wrote):

> AliasMatch ^/foo/(.*)  /home/WWW-data/349/$1

This should work.. 
^ means "from the beginning of the string"
() means "trap this in $1"
. means "any character"
* means "zero or more of the preceding characters"

Rgds,

Owen Boyle.

---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Alias works fine, AliasMatch breaks ??

Posted by Ryan <rp...@willconsult.com>.
 > AliasMatch ^/foo(.*)  /home/WWW-data/349$1

Thanks Owen, that worked.  But if someone puts in /foo5/, that ends up 
getting aliased to /home/WWW-data/3495/, which is someone else's 
directory.  I tried to anchor it to the end of the string with ^/foo/(*.) 
but that didn't work.  Is it possible to make it match only match /foo/ ?

-Ryan


At 11:20 AM 2/28/2002 +0100, you wrote:
>Ryan wrote:
> >
> > I have an alias setup, like
> > Alias /foo  /home/WWW-data/349
> >
> > I now need to be a little more flexible on how people reach /foo, so I'm
> > trying to use AliasMatch.  But even without putting any regexp's in there,
> > AliasMatch doesn't work.  I'm using
> > AliasMatch /foo  /home/WWW-data/349
> >
> > When I try to pull up /foo, I get the page thats usually served from my
> > default virtual host (the fist one listed in httpd.conf). Very
> > strange.  Any ideas?  The docs say AliasMatch works just like Alias, except
> > it allows regular expressions.  But its not working like that for me.
>
>I rather think the docs mean AliasMatch serves the same general function
>as Alias but that it uses regular expressions - I don't think you can
>literally replace "Alias" with "AliasMatch". In other words, AliasMatch
>*needs* regular expressions to work. If you have just:
>
> > AliasMatch /foo  /home/WWW-data/349
>
>then this will never match because "http://servername/foo" will be
>re-directed to "http://servername/foo/" (i.e. trailing slash gets added)
>which will translate to "/foo/" which won't match. So you'll get the
>default server. Try going by the example in the docs and put:
>
> > AliasMatch ^/foo(.*)  /home/WWW-data/349$1
>
>and see what happens.
>
>Rgds,
>
>Owen Boyle.
>
>---------------------------------------------------------------------
>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
>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
For additional commands, e-mail: users-help@httpd.apache.org


Re: Alias works fine, AliasMatch breaks ??

Posted by Owen Boyle <ob...@bourse.ch>.
Ryan wrote:
> 
> I have an alias setup, like
> Alias /foo  /home/WWW-data/349
> 
> I now need to be a little more flexible on how people reach /foo, so I'm
> trying to use AliasMatch.  But even without putting any regexp's in there,
> AliasMatch doesn't work.  I'm using
> AliasMatch /foo  /home/WWW-data/349
> 
> When I try to pull up /foo, I get the page thats usually served from my
> default virtual host (the fist one listed in httpd.conf). Very
> strange.  Any ideas?  The docs say AliasMatch works just like Alias, except
> it allows regular expressions.  But its not working like that for me.

I rather think the docs mean AliasMatch serves the same general function
as Alias but that it uses regular expressions - I don't think you can
literally replace "Alias" with "AliasMatch". In other words, AliasMatch
*needs* regular expressions to work. If you have just:

> AliasMatch /foo  /home/WWW-data/349
 
then this will never match because "http://servername/foo" will be
re-directed to "http://servername/foo/" (i.e. trailing slash gets added)
which will translate to "/foo/" which won't match. So you'll get the
default server. Try going by the example in the docs and put:

> AliasMatch ^/foo(.*)  /home/WWW-data/349$1

and see what happens.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org