-1

I have PHP5 installed on an Ubuntu 14.04 server and it works fine. I create a file called foo.php anywhere in the document tree and it gets passed to the PHP interpreter just as you'd expect.

However... I don't want the .php extension to be visible in one particular case so I created a symbolic link using "ln -s foo.php foo". If I go to http://localhost/path/to/foo.php then PHP works just fine, but when I go to http://localhost/path/to/foo then I see the PHP source.

I'm guessing that this is because the SetHandler directives in /etc/apache2/mods-enabled/php5.conf are in a <FilesMatch> directive and my filename doesn't end with ".php", but I've got FollowSymlinks enabled, so I was expecting that not to matter. I guess it does.

I know I could use mod_rewrite to do an internal redirect, but that's a bit of a sledgehammer. I could also use Redirect, but that pushes the redirection back to the client, which I want to avoid.

So is there an easy way to tell Apache "follow the symlink, then do auto-type determination based on the found file"?

kbro
  • 193
  • 1
  • 1
  • 8

1 Answers1

0

Looking at http://httpd.apache.org/docs/2.4/mod/core.html#options it says

Even though the server follows the symlink it does not change the pathname used to match against <Directory> sections.

I imagine the same is true for matching against <Files> sections, so it can't be done. However, this comes close:-

<Location "/path/to/foo">
  SetHandler x-foo-handler
  Action x-foo-handler /path/to/foo.php virtual
</Location>
kbro
  • 193
  • 1
  • 1
  • 8