1

Running Apache on Mac Snow Leopard (ie Web sharing enabled).

Paths are evaluating in ways not expected:
example.com/folder is returning a file (sans exception) instead of a folder.

If I make a call to example.com/events/March and I have a file events.php in my root directory, Apache returns that page, and the rest of the path is ignored.

Furthermore, this call takes precedence over the commands in .htaccess

eg. I need example.com/events/March to redirect to example.com/events.php?month=March
Apache returns example.com/events.php without the requisite argument.

RewriteEngine on
RewriteRule ^events/(.+)/?$ events.php?month=$1

If the events.php doesn't exist (let us say it is called eventsHandler.php), then the above rewriteRule works wonderfully. So I know it is not an issue with the .htaccess

I've tried to make file extensions visible, it has not helped.

So the questions are:

  1. Why does Apache on Mac drop the file extension and treat the file as a folder?
  2. Why doesn't the .htaccess overrule this?
  3. How do I fix this, that it should just work?
SamGoody
  • 111
  • 3

1 Answers1

0

On MacOS, a slash ("/") is a valid character for use in filenames and is not a path delimiter. Try using a colon for the path delimiter instead.

Also, be sure to test your paths in all the code you depend on because you may occasionally encounter some code that will try to automatically convert paths after detecting the OS. We ran into some issues like this back in the Novell NetWare days (not with NetWare, which supported multiple file system naming conventions on a single volume by adding something called a "namespace" on the server-side, but with third-party tools and libraries that can sometimes introduce confusion).

Pascal Cuoq
  • 141
  • 2