I am building a web application for questions and answers. Each question/answer page has all the required metadata for Facebook and Twitter, and we encourage users to share these pages.

I have a dilemma regarding the shared link structure:

Option 1 - subdomains

Use a questions.example.com and answers.example.com, followed by an ID and optional text. The text is ignored by the request, which only takes the id into account.

http://questions.example.com/12345/how-long-is-the-queue    # Example
http://q.example.com/12345                                  # Example

Option 2 - URL path

This is the format used by stackoverflow.com and trello.com:

http://example.com/questions12345/how-long-is-the-queue    # Example
http://example.com/q/12345                                 # Example

Server-wise, I can easily do both - I have a wildcard SSL certificate and Apache/NGinx configuration is pretty straightforward.

Which option - subdomains or URL path - is preferred for shareble links?

  • Or http://example.com/how-long-is-the-queue as ideally each question would have unique text for the name wouldn't it? – Steve Aug 20 '14 at 6:57
  • No necessarily. "yes" or "no" are pretty common answers, and "what's up" a common question - hence the unique id. – Adam Matan Aug 20 '14 at 7:06
  • Oh I didn't get from the question that people were dynamically asking questions. – Steve Aug 21 '14 at 10:19
  • Sorry for not being clear enough - updated. – Adam Matan Aug 21 '14 at 10:25
  • Don't forget to approve the answer if you like it. – Jérôme Verstrynge Aug 25 '14 at 17:19

Both are fine, but the URL path has a slight benefit over subdomains, because the backlink juice would be concentrated on one domain. Managing one domain is also easier than multiple subdomains.

In all cases, I would put the id of the question/answer in the url, because it will make the url unique for sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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