Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Some websites, no matter what page you're on, always just show their domain name in the address bar and nothing else.

And many show the folders, e.g. http://superuser.com/questions/ask, but don't show the actual file, which would be like http://domain.tld/folder/file.extension.

How are both accomplished?

share|improve this question

3 Answers 3

up vote 9 down vote accepted

This is because of a bit of a misconception with what a URL actually is, probably helped by the days of static .HTML files and PHP scripts.

Traditionally, everything past the TLD is a pointer to a specific file. Say a blog post is located at example.com/blog/2009/oct/18/what-have-we-come-to. Without the use of fancy techniques, it would mean that there is a folder called blog, and in that is a 2009 folder, and in that a folder for every month, and in those folders ANOTHER folder for every day of the month. Clearly, this gets very complicated very quickly.

That is why web servers (such as Apache) and programming languages (such as PHP) invented URL rewriting. What that does is converts the said URL into something a bit more manageable, such as example.com/blog/articles.php?id=423. Here, a the articles.php script will use the provided post ID to look up the applicable post, then it will display the post, but the user would still see the URL as example.com/blog/2009/oct/18/what-have-we-come-to.

Another approach just scraps all this entirely. Everything past the TLD (in this case, /questions/56772/website-url-hiding-hiding-file) is merely a pointer to content, not necessarily a file. Some websites, such as Super User, a built using a MVC (Model-View-Controller) approach. Usually, this involves a list of URLs for a website, and maps them to the applicable functions and code in order to display that page. For example, Super User might look like this1:

'superuser.com/' > displayFrontPage()
'superuser.com/questions/' > displayQuestionsList(sorted=default)
'superuser.com/questions/<QuestionID>/<QuestionID>' > displayQuestion(question= QuestionID)

This would most commonly be placed in a file by itself. I a common layout might be:

superuser/
          controller.aspx (which contains the list of URLs and points to a view in views.aspx)
          views.aspx (which contains all the code for the superuser, such as displayFrontPage() and displayQuestion(question= QuestionID))
          models.aspx (which contains information about the table in the database.)

1Please keep in mind that I have no idea how the controller works for ASP MVC (I am more of a Django guy), so this probably isnt that accurate. It is just an example

share|improve this answer
    
Where would that code be placed? –  Mk12 Oct 17 '09 at 23:48
    
It would depend on the server configuration or the actually framework being used. I will update my question appropriately. –  David Pearce Oct 17 '09 at 23:53
    
What about google, for instance google.com/search?client=safari&rls=en&q=superuser&ie=UTF-8&oe=UTF-8, notice search has no file extension… –  Mk12 Oct 18 '09 at 19:38
    
@Mk12: The programmer can choose to use any URL he/she wants. I could write a web application that puts .php at the end of every URL, when in fact there are no PHP files anywhere on the server. So Google decided to simply use "search" without any extension. They could have done something like this, if they had wanted (and it wouldn't have actually changed anything): google.com/search/client=safari/q=superuser/ –  Sasha Chedygov Oct 18 '09 at 19:40
    
Anyway, +1, good description. –  Sasha Chedygov Oct 18 '09 at 19:41

The file is a default as defined in the web servers config, or it's using URL re-writing (the folder path might not even exist).

share|improve this answer
    
Oops... forgot to address the domain name only question... This can be done by using a frameset, and only having the content's frame shown. –  AbsCoder Oct 17 '09 at 23:22
    
You can edit your answer instead of writing a comment. –  Sasha Chedygov Oct 18 '09 at 19:39
    
IIRC, a person with a reputation of 1 can't edit his own posts. –  CarlF Oct 18 '09 at 21:52
    
There, he can edit! Abs, would you mind editing your answer to include the comment? –  David Pearce Oct 21 '09 at 1:55

What I was really looking for, is this: Just create a directory, have index.php/html inside the folder, and links to that directory won't show the file. Thanks for the other things too.

share|improve this answer
1  
That's really more of a hack...url rewriting or content pointers are more commonly how it's accomplished –  Chris Thompson Oct 20 '09 at 23:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.