Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Extensionless Files Different Methods, Same Result polarbear msg:3270264 10:22 pm on Mar 3, 2007 (gmt 0) Howdy,
I've been reading a lot about extensionless URLs and the different ways to accomplish them.
I want to use the following method with php:
I save php files without any extension on my server (e.g. "foo", not "foo.php"). I add " DefaultType application/x-httpd-php" to my .htaccess to make apache treat extensionless files like php-files. I also add the following code to my .htaccess to remove trailing slashes from URLs if they refer to extensionless files (but not directories):
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]
Since I'm not much of an expert I'd like to ask if there's anything wrong with my approach. I have read
jdMorgan's post [ webmasterworld.com] that says:
The right way to do this is name the files as .php, and then rewrite the URLs that have no extension to those filenames using mod_rewrite.
I figured that my way would be slightly faster than a method including mod_rewrite. Am I missing anything here? Could I run into some unforseen trouble with this method?
jdMorgan msg:3270390 2:10 am on Mar 4, 2007 (gmt 0)
If it works, it works...
Test it to be sure.
spinnercee msg:3270677 3:09 pm on Mar 4, 2007 (gmt 0)
I'd be careful using DefaultType because in addition to extensionless files, it will also apply that content-type to extensions that are not specified in mime.types or via httpd.conf directives -- this could crash or at least slow your HTTPd by allowing PHP to attempt to parse/run files it has no way of handling.
Apache can run PHP files without extension wherever scripts/CGI can run as long as their first line is a declaration to the executable that loads them: