Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Hello folks, I'm wondering how is the following algorithm is done on SO: 1.As you know the link to the question is generated from keywords pulled from title.

And secondly: 2.After the link is generated and clicked (to view the question), what is the logic to get the question from the database.

Thank you.

share|improve this question
The words in the URL are called the slug. – Arjan Apr 22 '11 at 17:31
up vote 1 down vote accepted

To get title from link

Link generating from title of question,

There is an API call like this.

The result JSON has title field

  "total": 1,
  "page": 1,
  "pagesize": 30,
  "questions": [
      "tags": [
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/88495/timeline",
      "question_comments_url": "/questions/88495/comments",
      "question_answers_url": "/questions/88495/answers",
      "question_id": 88495,
      "owner": {
        "user_id": 158735,
        "user_type": "registered",
        "display_name": "Doolkin",
        "reputation": 11,
        "email_hash": "1c8c4244b096549213b105c0f52211b1"
      "creation_date": 1303493001,
      "last_activity_date": 1303493001,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 2,
      "score": 0,
      "community_owned": false,
      "title": "Link generating from title of question"

And href attribute of link has question id.

<a href="">
Link generating from title of question
share|improve this answer
And this : /questions/88495/answers means that there is a new folder for every single question ? – Doolkin Apr 22 '11 at 17:30
There aren't actually any folders, Doolkin. The Stack Overflow software on the server parses the whole URL to determine what content to send back to the client. – Rob Kennedy Apr 22 '11 at 17:32
@Doolkin, those are not folders, just a url rewriting to a question or answer view page. – YOU Apr 22 '11 at 17:32
@YOU , can you give me a simple clue how is this done, i mean the rewriting (how it works). Thanks buddy – Doolkin Apr 22 '11 at 17:36
@Doolkin, please don't use this as a forum. You've asked the same thing in a comment on Rob's answer. – Arjan Apr 22 '11 at 17:36
@ Arjan , i'm sorry about this you are right. @YOU thank you buddy, now i understand. Cheers – Doolkin Apr 22 '11 at 17:39
@Doolkin, no problem, you could search those url rewrite related posts on stackoverflow search, IMHO. – YOU Apr 22 '11 at 17:40

Questions have an unlimited numbers of addresses. The important part is the question ID number. (This one's is 88495, for example.) That's how the question is fetched from the database. For lookup purposes, the rest of the text is ignored; it's only there to make it easier for humans to get an idea of where the link goes, and also for search engines to assign more weight to a result because it has the search terms in the URL.

share|improve this answer
The slug is not used, but it still is enforced with a 301 Moved if it's wrong. – Arjan Apr 22 '11 at 17:34
Ye, and since there is an id number (88495) into href tag, which is not attached to a variable like .php?quesion=88495, its an a directory path, so this means that there is a new dir, for any question? – Doolkin Apr 22 '11 at 17:34
Ai, @Doolkin, that 's a question a bit too broad to be answered here. No, the questions are not on the file system but are fetched from a database. The web server tells some script "here's the full URL, give me some content". – Arjan Apr 22 '11 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .