Page 1 of 2
File Extensions
Posted: Sun Jul 24, 2005 2:11 am
by thesimon
Posted: Sun Jul 24, 2005 2:16 am
by Revan
There is no more 'professional' way, it's like asking which is more professional, print, or echo?
Posted: Sun Jul 24, 2005 3:04 am
by thesimon
True, very true.
But I suppose the most obvious question is, which do you prefer? What do you use?
Besides, if i use echo or print, the end user will not see any difference.
Posted: Sun Jul 24, 2005 4:54 am
by timvw
Apparently people (and the webserver) seem to like/handle files differently based on the ending of their name.. But without really verifying the content of the file (no prejudices allowed) you don't know for sure... Well, Microsoft thinks differently, and that explains why you can do .exe.gif tricks
So, apart from technical reasons (it's silly to pass each plain html file to the php parser) it's all subjective. (I believe in good content and not companies that try to sell SEO BS)
I've seen people that choked if you give them an URL without a www at the beginning.. I think it easier to remember example.com/contact than example.com/contact.php or example.com/contact.asp... But the most usable (imho) is to surf to example.com and click on the "contact" button...
The difference between
print and
echo is explained in the manual

Posted: Sun Jul 24, 2005 4:54 am
by Revan
thesimon wrote:True, very true.
But I suppose the most obvious question is, which do you prefer? What do you use?
Ah, well I prefer just using file.php, but if it's a complex site, I use mod_rewrite to turn urls into "
www.site.com/contactus/1/3"
Posted: Sun Jul 24, 2005 8:26 am
by Ambush Commander
I read once that doing it without the *.php extensions helps if you ever decide to move technologies: no bookmarks break, and it's transparent to the user.
That being said, implementing this well will require a bit of Apache hacking, so if you're on shared hosting, it's probably not a good idea.
Google uses search?q=bang note how it still uses GET variables, it just zapped the extension. That's how I suppose I would do it.
Posted: Sun Jul 24, 2005 8:30 am
by thesimon
Is there any easy way to "zap" the .php using the .htaccess. I am on reseller hosting, so i do not have much control.
Thankyou for your help so far, this is very interesting.
Posted: Sun Jul 24, 2005 8:32 am
by Ambush Commander
It's mod_rewrite, I'm sure. Unfortunantely, I'm not well versed in the "Voodoo" comparable to "sendmail", so I can't help you.
Re: File Extensions
Posted: Sun Jul 24, 2005 9:05 am
by Roja
thesimon wrote:Whats the most professional way when it comes to page extensions and url passing?
Ambush hit the nail on the head: Leave off the .php!
From
W3c's "cool uri's" page:
File name extension. This is a very common one. "cgi", even ".html" is something which will change. You may not be using HTML for that page in 20 years time, but you might want today's links to it to still be valid.
As to how? Its easy. By default, Apache will do content scanning. In other words, if there is no extension, it goes through a list to find a good match. If you said,
http://www.example.com/something , then it would look in the /public_html dir for:
something.html
something.php
etc
If there is only one match (ideally), thats the one it will use. No hacking required. IIS acts similarly. The only requirement for both is that the webserver must be aware of PHP (.php) as a content type.
Easy!
Posted: Sun Jul 24, 2005 9:08 am
by Ambush Commander
You're right! That's pretty awesome! Although those interested in saving their CPU from a few extra cycles should use mod_rewrite just to make sure Apache knows exactly where to look.
Posted: Sun Jul 24, 2005 9:11 am
by Roja
Ambush Commander wrote:You're right! That's pretty awesome! Although those interested in saving their CPU from a few extra cycles should use mod_rewrite just to make sure Apache knows exactly where to look.
Actually, if there is only one choice in the directory, mod_rewrite will use more cpu cycles.

Posted: Sun Jul 24, 2005 9:14 am
by Ambush Commander
That is true.
Posted: Sun Jul 24, 2005 10:20 am
by nielsene
You don't have to use mod_rewrite, you can also just use the ForceType directive, normally much easier....
Posted: Sun Jul 24, 2005 10:42 am
by bokehman
There certainly is a wrong way and that is using a query string to serve static pages. It is similar to using tables fo layout, it is wrong but you see it everywhere on the web.
For me the most professional way is any way that is easy for the viewer. So 'cats.com/pedigree/persian' is a lot easier than '
www.cats.com/index.php?type=pedigree&breed=persian'. If anyone prefers typing the second one please see a psychiatrist!
Posted: Sun Jul 24, 2005 10:49 am
by nielsene
My preferred way (and how I'm slowly converting most of my sites) is the
host.domain/scriptname/var1/var2/var3
style, where var1..3 are things that define a page. (Like the cats.com/pedigree/persian/ example above)
This still looks "friendly" to me. The end user can tell exactly where a mailed/bookmarked link will be going and have to try to remember a long string of "gobblygook".
If something truly is a form then GET/POST can still be used, but "templated pages" should be given nice URLs.
I don't like overloading a single scriptname with too much extra stuff, so I try to keep them very focuses (not the one page serves an entire site model).
I often submit forms to an "interstitual" page that then redirects where needed. Most such scripts will end up in a subdirectoty named SCRIPTS for me; these still have an extension but only visible to the user briefly in the location bar before the redirect (only under high server load, too).