I think it might be a good idea to have a URL-shortening service for each of the Stack Overflow family of sites.
Since questions, and answers all have a unique id, it should be fairly easy to use that for shortening the URLs.
For example: (Could easily be shorter)
http://short-SO-url.com/1234
This could easily point to a question, or an answer. All this would need to do is redirect to:
http://stackoverflow.com/questions/1234
Or if it is an answer, point to:
http://stackoverflow.com/questions/{question-id}/-/1234#1234
You need something between the question id, and the answer id. That is why there is /-/
in the URL.
Right now, if you want a shorter URL, you have to use a third-party URL shortener which can point to anywhere. It is also difficult, or impossible to know that it doesn't redirect to a malicious website. If there were an official URL shortener that only worked for Stack Overflow, you would know for sure that it is safe.
This would be easier if there was an internal interface to redirect to the correct URL.
http://stackoverflow.com/api/post/1234.301
It could redirect to the correct URL regardless of if it is an answer or a question. 301 redirect
6 Answers 6
The following is officially supported and redirects to the full URL (using a 302 Found):
Also, despite the /q
for /question
: if this happens to be an answer ID, it redirects properly too. But I am not sure if that is official too? Like:
...redirects to
meta.stackoverflow.com/questions/23834/official-shortened-url-service/75352#75352
(削除) Note that, before redirecting, the latter gets one a 404 † if the answer is deleted, even when the question still exists. The long URL would then take one to the question instead. (削除ここまで)
As an aside: exotic domain names, like Libya's .ly
as used by bit.ly, might not be very future proof.
† Users who can see deleted posts, won't get the 404. I guess that's the reason for the 302 Found
(along with Cache-Control: private
) rather than 301 Moved Permanently
.
-
Now: is this short enough? I guess Shog9 was right back in 2009.Arjan– Arjan01/18/2011 18:17:07Commented Jan 18, 2011 at 18:17
URLs on stack overflow are already pretty short, especially once you remove the post title and such. In your example, you aren't really saving that much. I think if you wanted something considerably shorter, you'd have to go to something like tinyurl has, and you'd end up with something like
http://stackoverflow.com/url/D839d8D
Which still wouldn't gain you much over the already pretty short url of
http://stackoverflow.com/questions/1234256
With answers, it gets a bit longer but I think that we could come up with a link to an answer like
http://stackoverflow.com/answers/1234256
and then a database lookup could be done to direct you to the correct question. Same thing could be done for comments.
Doing something like this for direct links to answers and comments would be much easier to costruct your own URL, and would keep much more to the MVC spirit of things.
-
1I was actually thinking it could be much shorter than the example in the question. I was thinking that it could be so short that the Post id could be the longest part of the url.Brad Gilbert– Brad Gilbert09/29/2009 14:57:18Commented Sep 29, 2009 at 14:57
-
4You can link to an answer like you would to a question; it will automatically be redirected: meta.stackexchange.com/questions/2383609/29/2009 15:08:26Commented Sep 29, 2009 at 15:08
-
4Great, so even for answers, we have pretty short URLs. shortened URLs are great for things like mapping sites where the url is 500 characters long. I don't think that stackoverflow really has a need for an official url shortener, as the urls are already pretty short.Kibbee– Kibbee09/29/2009 15:17:18Commented Sep 29, 2009 at 15:17
-
Also,
questions
andanswers
can be abbreviatedq
anda
: meta.stackexchange.com/q/23834Zaz– Zaz03/31/2013 12:00:42Commented Mar 31, 2013 at 12:00
What would be the benefit? Only thing I can think off the top of my head is less text to send back to the client, which I'm not sure outweighs the cost of maintaining the additional system.
-
8I was thinking someone could use it for Twitter.Brad Gilbert– Brad Gilbert09/29/2009 14:53:10Commented Sep 29, 2009 at 14:53
-
3Not only twitter, but any reference. Small urls are much more attractive than larger ones. They also look better when used inline in paragraphs, especially paragraphs that aren't really wide.Sampson– Sampson09/29/2009 15:21:35Commented Sep 29, 2009 at 15:21
-
5Small URLs are actually only better if the longer one is completely unreadable anyway. With MVC style URLs, where they are actually readable, and quite short already, you lose a lot when you move to a shortened url. I think it's much more "attactive" to have a reasonably sized URL that tells me exactly where it's going to go over a short url that tells me nothing. The short URL that tells me nothing is only more "attactive" when compared to extremely long URLs that tell me nothing.Kibbee– Kibbee09/29/2009 15:38:36Commented Sep 29, 2009 at 15:38
-
1What Kibbee said. The best part of SO URLs is the title at the end... Whoever thought hyperlinked tinyURLs were a good idea should be banned from ever using HTML again.09/29/2009 17:39:23Commented Sep 29, 2009 at 17:39
-
You could probably do the same thing that happens now, You can add anything after the post id.Brad Gilbert– Brad Gilbert09/29/2009 19:22:18Commented Sep 29, 2009 at 19:22
I think this is a good idea now that we have a "share on Twitter" button. I just used this for the first time and Twitter shortened the URL. If it's going to get shortened anyway, we should have our own shortener. As site owners, it would allow you to better keep track of what people are actually clicking on. Here's a screenshot:
alt text
-
Wow, Twitter needed to go all the way to Colombia to get the shortest possible domain? (Not really the shortest;
http://.to/
beats that.)Arjan– Arjan01/18/2011 18:05:30Commented Jan 18, 2011 at 18:05
We do have a URL shortener for sites, but it doesn't navigate to individual pages. Just sites.
-
Do you know why it won't navigate to individual pages?ChrisW– ChrisW11/17/2012 11:31:00Commented Nov 17, 2012 at 11:31
-
@ChrisW: Don't know -- you can put up a feature request here on meta if it's not already out there...Manishearth– Manishearth11/17/2012 11:44:29Commented Nov 17, 2012 at 11:44
-
I found an answer at meta.stackexchange.com/a/110462/139866ChrisW– ChrisW11/17/2012 11:52:14Commented Nov 17, 2012 at 11:52
Don't
post your own ideas for the domain name here, someone could register it before the Stack Overflow team could register it. If you really feel strongly about a domain name, send them an email instead.