Forum Moderators: phranque

Message Too Old, No Replies

AliasMatch and windows drive letters, directory-path escaping

         

Questionmark

5:02 pm on Sep 14, 2011 (gmt 0)

10+ Year Member



AliasMatch and windows drive letters, directory-path escaping

Hi, have an apache 2.2.9 under a winxp.
I've tried to trasform incoming url with AliasMatch.
My documentroot is set to n:/htdocs. I need to translate for example
http://myserver.mydomain/new/pages/something

to
http://myserver.mydomain/new/page.php?pageid=something



I wrote this simple AliasMatch rule:
AliasMatch (.*)pages/(.+) "n:/htdocs/new/page.php?pageid=$2"

(I know that this regex matches eg. [myserver.mydomain...] as well but it is doesn't matter now, it's just a try.)

I went to this addres with my browser:
http://myserver.mydomain/new/pages/something

and I got:
Forbidden You don't have permission to access /new/pages/something on this server.

and an error message appeared in apache log:
[Wed Sep 14 17:37:59 2011] [error] [client x.x.x.x] (20025)The given path contained wildcard characters: access to /new/pages/something failed


Ups, wildcard? Where? The colon was suspicious, I removed the drive letter:
AliasMatch (.*)pages/(.+) "/htdocs/new/page.php?pageid=$2"


The strange "wildcard" log message gone away. While browser displayed the "Forbidden" screen again, I got another message in the log:
[Wed Sep 14 18:31:28 2011] [error] [client x.x.x.x] client denied by server configuration: C:/htdocs

That's correct, apache.exe sits on c: so the path is based on c: and c:\htdocs is not configured in any <directory> directive (and is not an existing directory), so it is forbidden.

The colon gets more suspicious. But I cannot find any answer: is the colon char is a meta-char in directory-path part of AliasMatch? How to escape it? Backslash is not working for that.


Escaping is a general question looking at the directory-path part of AliasMatch, because the backreference is legal directory name (at least under windows).
Suppose I have this directory
c:/dir/$1
and I need to do something like this:
Eg.
AliasMatch (.*)pages/(.+) /dir/$1/$2

where the $1 is the directory and should be escaped, and the $2 is the backreference.
The doc of mod_alias says nothing about it.

?

Thanks in advance,
qm