Alias directive in Apache mod_alias module

Hi all,
I have a PowerMac G5 with Mac OS X Server 10.4.5.
I have some sites running on the server through the virtual host facility and, for one of them, I need to perform manipolations on a range of URL requests.
In the details of the site (Server Admin --> Web --> Settings --> Sites --> double click on the site from the list), I set the "Web folder" field to something like "/Library/WebServer/examplesite/B1234" and I need to modify all requests of type

http://mysite/B1234/xxxx/yyyy/file.ext

to

http://mysite/xxxx/yyyy/file.ext

I tried using the alias directive of Apache's mod_alias module (under the Aliases tab) setting an alias to something like

Alias /B1234 /library/webserver/examplesite

but it doesn't work.
If I look at the site's error log I see some entries like

[Tue Mar 14 17:04:23 2006] [error] [client 192.168.1.200] File does not exist: /Library/WebServer/examplesite/B1234/B1234/xxxx/yyyy/file.ext

So the Alias is doing nothing, and indeed if I remove it I get the some result.
What am I doing wrong and how can I achieve the result I described?
TIA

PowerBook G4 867MHz 12,1" Mac OS X (10.4.5)

Posted on Mar 14, 2006 7:53 AM

Reply
7 replies

Mar 14, 2006 3:21 PM in response to XFox

Alias /B1234 /library/webserver/examplesite/B1234

This sort of thing is also a good candidate for mod_rewrite, if you're adventurous.

Roger

Mar 16, 2006 2:08 AM in response to Community User

Yes, you're right, and indeed I have some requests of type http://mysite/xxxx/yyyy/file.ext and all works well, BUT ( as I explained in my firts post), I also have some requests of type http://mysite/B1234/xxxx/yyyy/file.ext that I need to remap to http://mysite/xxxx/yyyy/file.ext.
If I fail to do so, the clients end up to request the file http://mysite/B1234/B1234/xxxx/yyyy/file.ext, that doesn't exists.

PowerBook G4 867MHz 12,1" Mac OS X (10.4.5)

Mar 16, 2006 4:28 PM in response to XFox

I didn't really understand what you were trying to do, until this last reply. Anyway, looking around, it looks like the Alias directive basically has to be followed by a Directory stanza for the directory that the Alias points to.

Really what you're doing is redirecting the URL. The RedirectMatch directive will do this:

RedirectMatch ^/B1234(.*) http://mysite.com$1

Roger

Mar 17, 2006 2:25 AM in response to Community User

I've found the culprit: standard HFS+ filesystem is not case sensitive, standard Apple's Apache installation does.
If I try to insert an Alias, AliasMatch, Redirect or RedirectMatch directive through the Server Admin 10.4.4 (157.6) front-end, each time I click the Save button they are converted to all lower-case letters.
This completely breaks any directive that contains upper-case letters.
I'll file a bug report.

As a workaround, it's possible to manually edit the configuration file of your site (located in the /private/etc/httpd/sites folder) and add the directive between the <VirtualHost 192.168.1.200:16080> and </VirtualHost> tags.

Soluton 1:
Using the Alias directive, add:
<IfModule mod_alias.c>
Alias /B1234 /Library/WebServer/examplesite/B1234
</IfModule>


Soluton 2:
Using the RedirectMatch directive, add:
<IfModule mod_alias.c>
RedirectMatch temp ^/B1234(.*)
http://mysite.com$1
</IfModule>

Moreover, as Roger pointed out, the destination of an Alias directive must be covered by a [url=http://httpd.apache.org/docs/1.3/mod/core.html#directory]<Directory>[/url] section. In this particular case, however, it's not necessary to specify an additional <Directory> directive because (if you specified /Library/WebServer/examplesite/B1234 in the Server Admin's "Web Folder" field) it is already present in the configuration file.

Mar 17, 2006 3:31 PM in response to XFox

Glad you got it. Nothing like a GUI to screw things up!

I noticed on that VirtualHost tag that it's listening on port 16080. That means that the performance cache is on. IMO, the performance cache is useless, it only causes problems with the setup. I recommend turning it off.

I also recommend setting MaxRequestsPerChild to something uder 100, way under 100 if you're running PHP.

Roger

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Alias directive in Apache mod_alias module

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.