tags:

views:

67

answers:

3

I don't know if this is an Apache or PHP thing but if you go to either of:

mysite.com/about
mysite.com/about/

it will show the mysite.com/about.php file instead of a 404 error, because the directory does not exist.

I am sure this is some setting, maybe an htaccess thing, any ideas?

+3  A: 

That's not default behavior, for sure, so it's hard to say. If that were happening on the Apache side, look for a sequence of rewrite matching instructions; they'll likely begin with RewriteCond and ending with RewriteRule.

If you don't see anything like that in your VirtualHost config or site .htaccess, it's being managed by whatever PHP framework you're using, and you'll need to configure things there instead.

John Feminella
+1 That is definitely not a default PHP / Apache setup. I'm suspecting a `mod_rewrite` directive or that one module that can suggest alternative file names for incomplete request, I forgot its name...
Pekka
+3  A: 

As others have answered it might be a mod_rewrite rule; there is also a directive called MultiViews that is explicitly for enabling the functionality you describe.

http://httpd.apache.org/docs/2.2/content-negotiation.html#multiviews

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements.

Look for

Options MultiViews

in your httpd.conf or virtualhost-specific config file.

meagar
thanks a lot thats exactly what I was looking for!
fire
Glad to help. MultiViews is great for some (prevents a lot of playing with .htaccess files and mod_rewrite rules) and the bane of others.
meagar
A: 

with this .htaccess you can parse, with $_SERVER[REQUEST_URI] in the PHP side, the complete URL and then perform your desired action, this is a general way, you should consider error controlling and 404 redirection:

ErrorDocument 404 /404.php
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

and int the PHP side, that should be this index.php

$URLarray = explode('/', $_SERVER['REQUEST_URI']);
Joaquín L. Robles
Not really relevant to the question...
meagar