File Extensions
Moderator: General Moderators
File Extensions
Hey Guys,
Whats the most professional way when it comes to page extensions and url passing?
eg
http://www.site.com/contactus.php
http://www.site.com/contactus.html
http://www.site.com/contactus/
http://www.site.com/contactus.php?id=1
http://www.site.com/contactus/1/3
Whats the most professional way when it comes to page extensions and url passing?
eg
http://www.site.com/contactus.php
http://www.site.com/contactus.html
http://www.site.com/contactus/
http://www.site.com/contactus.php?id=1
http://www.site.com/contactus/1/3
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
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
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"thesimon wrote:True, very true.
But I suppose the most obvious question is, which do you prefer? What do you use?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
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.
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.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: File Extensions
Ambush hit the nail on the head: Leave off the .php!thesimon wrote:Whats the most professional way when it comes to page extensions and url passing?
From W3c's "cool uri's" page:
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: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.
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!
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Actually, if there is only one choice in the directory, mod_rewrite will use more cpu cycles.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.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
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!
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!
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).
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).