logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: AliasMatch problems
Author
fatted



Joined: 12 Apr 2007
Posts: 6

PostPosted: Thu 12 Apr '07 16:22    Post subject: AliasMatch problems Reply with quote

Hi,

I'm trying to map a url of the form

http://www.webserver.com/zonexx/

to a directory on the system:

/opt/share/zonexx/

Where the xx in zonexx are 2 digits (zone01, zone42,...).

So I have an AliasMatch line in my httpd.conf of:

AliasMatch ^/(zone[0-9]*)/ /opt/share/$1

However if I try to access the url say:

http://www.webserver.com/zone11/

It tries to return:

http://www.webserver.com/zone11/index.html/index.html/index.html/....

repeating the index.html 15 or 20 times...

What am I doing wrong?

Cheers!
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 13 Apr '07 6:09    Post subject: Reply with quote

Unlike Alias, AliasMatch does not work with just a URI prefix, but with the whole URI.

I think you want this:
    AliasMatch ^/(zone[0-9]*/.*) /opt/share/$1

What's going wrong with your current regex is:
    1 - your pattern translates /zone11/ to /opt/share/zone11
    2 - since this is a directory, Apache appends index.html to the URI
    3 - your pattern translates /zone11/index.html to /opt/share/zone11
    4 - since this is a directory, Apache appends index.html to the URI (again!)
    5 - your pattern translates /zone11/index.html/index.html to /opt/share/zone11
    6 - etc., etc.


-tom-

p.s. If "zone" must always be followed by exactly two digits, and you don't want to require a trailing slash; this might be a better regex to use:
    AliasMatch ^/(zone[0-9]{2}(/.*)?) /opt/share/$1
which means $1 is "/zone followed by exactly two digits, optionally followed by (a slash followed by zero or more characters)".

-t-
Back to top
fatted



Joined: 12 Apr 2007
Posts: 6

PostPosted: Fri 13 Apr '07 11:22    Post subject: Reply with quote

Thanks for the help!

I've tried this:

Quote:
AliasMatch ^/(zone[0-9]*/.*) /opt/share/$1


But some other craziness Smile is now going on:

Make request:

http://www.myweb.com/zone12/

Browser (firefox), throws back as before:

http://www.myweb.com/zone12/index.html/index.html/index.html/....

And the access.log has the same request:

x.x.x.x - - [13/Apr/2007:10:05:02 +0100] "GET /zone12/index.html/index.html/...(etc) HTTP/1.1" 404 484

But the error.log has:

[Fri Apr 13 10:05:02 2007] [error] [client x.x.x.x] File does not exist: /opt/share/zone12/index.html

(which is what I'd expect to happen because the index.html file doesn't exist, but this doesn't match the access.log request...).

However when I create the index.html file, the access.log still reports the same error, but the error.log has changed to:

[Fri Apr 13 10:15:38 2007] [error] [client x.x.x.x] File does not exist: /opt/share/zone12/index.html/index.html/...(etc).

Any idea's?
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 13 Apr '07 14:49    Post subject: Reply with quote

Just checking .... you are using Apache 2.2, and you restarted Apache after changing httpd.conf?

I set up a similar config on Apache 2.2.4 and reproduced your exact symptoms with:
    AliasMatch ^/(zone[0-9]*)/ /opt/share/$1

It worked OK with:
    AliasMatch ^/(zone[0-9]*/.*) /opt/share/$1

    -or-

    AliasMatch ^/(zone[0-9]{2}(/.*)?) /opt/share/$1


-tom-
Back to top
fatted



Joined: 12 Apr 2007
Posts: 6

PostPosted: Fri 13 Apr '07 15:51    Post subject: Reply with quote

Quote:
Just checking .... you are using Apache 2.2, and you restarted Apache after changing httpd.conf?


Apache 2.0.58
Back to top
fatted



Joined: 12 Apr 2007
Posts: 6

PostPosted: Fri 13 Apr '07 15:52    Post subject: Reply with quote

Quote:
and you restarted Apache after changing httpd.conf?

yes Smile
Back to top
fatted



Joined: 12 Apr 2007
Posts: 6

PostPosted: Fri 13 Apr '07 16:54    Post subject: Another way Reply with quote

Maybe I should try this from a different angle:

How do I get the AliasMatch to display the directory contents instead of looking for an index.html? (and spiralling off into a loop)

(Similar to say "Alias /docs/ /opt/shares/" will display the contents of the directory /opt/shares/ and not return a couldn't find index.html message).
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 13 Apr '07 17:12    Post subject: Reply with quote

I don't get it....

As a test, I installed Apache 2.0.58 on a Linux (Debian Etch) system and configured it with the same directory names you are using - /opt/share/zoneNN.

I still see your exact symptoms with the original regex, but either of the two regex's I proposed corrects the problem on my system.

Do you have any other Alias* or Rewrite directives which might be contributing to the problem?


-tom-
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 13 Apr '07 17:26    Post subject: Reply with quote

One thing I noticed - be sure to clear your browser cache as well as restart Apache,
lest your browser makes it look like the new regex's don't work when they actually do.

-tom-
Back to top
fatted



Joined: 12 Apr 2007
Posts: 6

PostPosted: Fri 13 Apr '07 17:57    Post subject: Reply with quote

Quote:
be sure to clear your browser cache


I'm officially a muppet Embarassed

Thanks for your help!
Back to top


Reply to topic   Topic: AliasMatch problems View previous topic :: View next topic
Post new topic   Forum Index -> Apache