views:

40

answers:

2

I have a file

http://www.www.com/somefile.php

I would like to be able to get to the same file by going to

http://www.www.com/somefile

But I still need

http://www.www.com/directory

to open the file

http://www.www.com/directory/index.php

if, in fact, directory is a directory.

This is a typical LAMP setup with Red Hat and Apache.

Is that possible? If so, how?

+2  A: 

Look at Apache's ForceType.

Eric Butera
+3  A: 

An apache rewrite rule will do this for you. The only limitation is you can't have a file named "somefile.php" and a directory named "somefile" (though you can still have directories.

Here's an example rule that supports multiple filenames (just put in in your .htaccess file).

RewriteEngine on
RewriteRule ^(somefile1|somefile2|somefile3) $1.php

Will change /somefile1 to /somefile1.php, /somefile2 to /somefile2.php, and /somefile3 to /somefile3.php.

SoapBox
^ This. Don't rename your file, just change how Apache matches URLs to filenames.
Ben Blank
Thanks, that did it.
Jason