Forum Moderators: phranque

Message Too Old, No Replies

Apache configuration issue: Default file in middle of URL

         

segnosaur

7:26 am on Apr 13, 2010 (gmt 0)

10+ Year Member



I've run into a rather, well, unusual problem. I've been doing searches through various forums but haven't come across anything. I thought someone here might have a suggestion or 2.

We currently have an application written in PHP (5.3) running on a Linux server running Centos (5) and Apache (2). The application runs fine on the server.

However, I need to duplicate the environment on a new server. (Same version of PHP/Apache/Linux). Now, here's the problem:

The 'default' file for the application is called 'index.php' (and its included in the DirectoryIndex directive in the apache configuration files.) So, I can use either:

h t t p://<mysite>/index.php
or
h t t p://<mysite>/

And both of these work on both the old and new server. (If you don't supply the 'index.php', the configuration files know that that is the name of the routine to call anyways.)

Now, the application has been set up to use parts of the URL to pass information into the application. So, it uses:


h t t p://<mysite>/index.php/somestuff
- - - -----------------------^^^^^^ Where 'somestuff' is extra information passed to php

Here's where I run into problems: In the site I'm trying to replicate, they (the original site authors) have done something unexpected to apache. Somehow, they've set things up so that:

h t t p://<mysite>/index.php/somestuff
and
h t t p://<mysite>/somestuff

are functionally equivalent. (i.e. the second line manages to find and execute the php script.) However, when I try to use the same URL on my site, it fails (with a 404). So, they have Apache set up to find default PHP files when its theoretical location is embedded in the middle of a URL, while my setup can only find the default PHP when the end location is a directory.

Anyone have any idea how they may have done this? (I've tried adding various aliases to the apache config files, specified the default in the .htaccess file, etc., but no luck so far.) The problem might be the AcceptPathInfo directive, but if that was an issue wouldn't it have also failed when the URL contained the index.php too?

Unfortunately nothing was documented, and configuration files are spread out among the standard httpd.conf file, directives in the conf.d directory, and .htaccess entries..

The people who set up the original Apache server were either really really brilliant, or really really dumb. Can't quite figure out which it is.

g1smd

5:08 pm on Apr 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I despair whenever I see a URL with
index.php [b]slash[/b] something
within.

I instantly know that the programmer failed to realise that URLs and files are not the same thing; they are merely 'associated' by the action of a server. There is never a reason for index.php to appear in any URL. URLs never need to divulge the technology the server will employ to deliver the content.

I would have initially asssumed they did a rewrite to make those URLs work. If that isn't located in the
.htaccess
file, then it could be located in
httpd.conf
or equivalent. There's a possibility that
AcceptPathInfo
is also involved, though I personally always turn that off.

Your programmers were clever in using rewrites, but totally dumb to arrange the parameters in the way that they did. :)

jdMorgan

6:02 pm on Apr 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See AcceptPathInfo (Apache 2.x only) in "Apache core" documentation.

Example:
 AcceptPathInfo On 


Jim