• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Apache web server confg question - Finding default php file

Segnosaur

Penultimate Amazing
Joined
Jan 18, 2002
Messages
21,816
Location
Canada, eh?
I've run into a rather, well, specialized problem at work. I've been doing searches through various forums but haven't come across anything. I thought someone here might have a suggestion or 2.

I'm working on setting up an application written in PHP on an Apache/Linux web server. I need to create a replica of a web site that exists on another server.

Now, the 'default' file is called 'index.php' (and its included in the apache configuration files.) So, I can use either:
http://<mysite>/index.php
or
http://<mysite>/
And both of these work. (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:
http://<mysite>/index.php/somestuff
--------------------------^^^^^^ Where 'somestuff' is extra information passed to php

Here is the problem: In the site I'm trying to replicate, they (the original site authors) have done something strange to apache. Somehow, they've set things up so that:
http://<mysite>/index.php/somestuff
and
http://<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 aliased to the apache config files, specified the default in the .htaccess file, etc., but no luck so far.)

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.
 
That sounds almost exactly how MediaWiki sets up its index page.
 
That's URL rewriting. Google it. Look up mod_rewrite.

Thanks. That actually helped me fix the problem.

Turns out that the new site alread had everything needed to set up url rewriting in the .htaccess file already in place. However, the main Apache config file had 'AllowOverride none', so it was never actually accessing the .htaccess file (and thus never applying the rules for the re-write.) Changing the AllowOverride directive fixed everything.

Thanks to your tip, I was able to locate and identify the problem.
 
Glad to be of help. I pointed you in the right direction, without providing the actual solution, and you had to learn something new. Let's go for a beer to celebrate. :)

Thanks. That actually helped me fix the problem.

Turns out that the new site alread had everything needed to set up url rewriting in the .htaccess file already in place. However, the main Apache config file had 'AllowOverride none', so it was never actually accessing the .htaccess file (and thus never applying the rules for the re-write.) Changing the AllowOverride directive fixed everything.

Thanks to your tip, I was able to locate and identify the problem.
 

Back
Top Bottom