Solved

A web page without extension (e.g. http://php.net/array )

Posted on 2006-06-14
7
866 Views
Last Modified: 2008-01-09
In some URLs, there is not extension to the "file" -- For example:
http://au2.php.net/array
http://en.wikipedia.org/wiki/Prokaryotes

Initially I thought they are Directories and there is an index.xxx inside the directories.... but I have tried index.php/asp/jsp/htm/html and they actually do not exist (in the two examples above)

so...what are they?? is "array" a file without an extension or what? If so, how can a web server process files without an extension?
0
Comment
Question by:jtjli
7 Comments
 
LVL 3

Expert Comment

by:jeaton32
ID: 16908488
Here's a clip I found from the W3C's website on URI's: http://www.w3.org/Provider/Style/URI.html

How can I remove the file extensions...

...from my URIs in a practical file-based web server?

If you are using, for example, Apache, you can set it up to do content negotiation. You keep the file extension (such as .png) on the file (e.g. mydog.png), but refer to the web resource without it. Apache then checks the directory for all files with that name and any extension, and it can also pick the best one out of a set (e.g. GIF and PNG). (You do not have to put different types of file in different directories, in fact the content negotiation won't work if you do.)

    * Set up your server to do content negotiation
    * Make references always to the URI without the extension

References which do have the extension on will still work but will not allow your server to select the best of currently available and future formats.

(In fact, mydog, mydog.png and mydog.gif are each valid web resources. mydog is content-type-generic. mydog.png and mydog.gif are content-type-specific.)

Of course, if you are building your own server, then using a database to relate persistent identifiers to their current form is a very clean idea -- though beware the unbounded growth of your database.
0
 
LVL 3

Expert Comment

by:jeaton32
ID: 16908495
jtjli,

Here's another link that looks a little more comprehensive:

http://www.websiteoptimization.com/speed/tweak/rewrite/

This article covers apache and IIS.
0
 
LVL 16

Accepted Solution

by:
OliWarner earned 300 total points
ID: 16908995
Yes its called URL rewriting... A URL shouldn't define what the data is so extensions are really quite useless on a practical level, especially when they just jumble up the URL with unneeded data.

I use URL Rewriting on my site to do a similar thing
http://www.thepcspy.com/articles/networking/browser_speed_comparisons

URL Rewriting pass everything after "http://www.thepcspy.com" into my index.aspx file as a querystring so the actual request is something like this:
http://www.thepcspy.com/index.aspx?page=/articles/networking/browser_speed_comparisons

I have built a pagehandler to read the querystring and decide what data needs to be displayed from there on...

For example it sees that it starts with /articles so hands it off to the article handler which then reads the section information "networking" and the cleaned up title "browser_speed_comparisons" and goes off to the database looking for the correct article and displays it.

That's a pretty complex example of URL Rewriting... You can use it just for one-off rewrites like a request for /page1.htm actually rewriting to the output of page1.asp

PHP will be using a system a bit like mine... perhaps not with the multiple handlers in the middle.


jeaton32 's link has some practical information on how to implement it in Apache. If you're using ASP.net v2 (like me) I suggest using URLRewriting.net
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 44

Expert Comment

by:scrathcyboy
ID: 16909086
For a URL like -- http://au2.php.net/array
what that really means is, there is some file in the "array" directory that is the "default" file for that dir.

There is a general heirarcy to observe, and it is usually in this sequence, 1 is first, 2 is next, 3 third, etc.
1.  array/index.html
2.  array/index.htm
3.  array/index.shtml
4.  array/index.php
5.  array/index.asp

SO there are many possibiliites, but there is a *default* file for each directory, like array.

What defines which file will be the default is the .htaccess file on each site.  Any person can code their .htaccess file to make the default file whatever they want it to be -- you as an outsider cannot discover this of your own accord, since the .htaccess file is hidden -- it is up to the site owner to decide that.

Read up on .htaccess files on the internet.  They are extremely powerful files to redirect web sites.
0
 
LVL 18

Assisted Solution

by:carl_legere
carl_legere earned 50 total points
ID: 16910733
in php anything is possible, many servers are tweaked to hide the real path (because it is virtial anyway) from the end users.  A quick check of this site http://au2.php.net/array with Efftech's http sniffer reveals that the requestor requested http://au2.php.net/array with HTTP GET and the reply has no real name.  I beleive that you are assumed to be english speaking and it uses the php code backend located at http://au2.php.net/manual/en/ref.array.php to render the page.

The clever redirects here aren't to protect these wiki's since I was able to download the whole thing with Teleport, but just makes it more organized to them.
0
 
LVL 8

Assisted Solution

by:netmunky
netmunky earned 150 total points
ID: 16912072
most often this is all done with apache mod_rewrite

for example, if you see
http://www.example.com/news/2523/this-guy-did-that-thing
and
http://www.example.com/news/2523/this-guy-did-that-thing/comments

you might see this in the apache config (.htaccess or httpd.conf)
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /news/([0-9]+)/.*/comments
RewriteRule .  /news.php?act=showcomments&id=%1
RewriteCond %{THE_REQUEST} \ /news/([0-9]+)/.*
RewriteRule .  /news.php?act=shownews&id=%1

anything that matches the part of the regular expression ([0-9]+) is put in place of %1, so you will actually be visiting
http://www.example.com/news.php?act=shownews&id=2523
and
http://www.example.com/news.php?act=showcomments&id=2523

mod_rewrite is to make URLs more reader friendly, but mostly because it can boost your rankings in search engines having the keywords in there ("this-guy-did-that-thing", if someone searches for "this guy")
0
 
LVL 4

Expert Comment

by:ansh_gupta
ID: 16912169
Basically we have something called wild card mapping in webservers. I will talk about IIS 6.0. We can have a programm on the server to process the request first then any other thing when any comes to a webserver.. So that programm knows about what to add to the request. Its just kind of security feature which hides the extensions and the special program set to process the requests will know how to handle that.  Its really normal..
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML table 7 55
Video on my site 4 28
Your suggestions for a Wordpress Theme 2 21
wordpress url rewriting plugin 5 11
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now