"Web 2.0"스타일 URL을 사용해야하는 이유는 무엇입니까? [닫은

StackOverflow https://stackoverflow.com/questions/475707

  •  19-08-2019
  •  | 
  •  

문제

요컨대, 왜 같은 것을 사용합니다 http://stackoverflow.com/badges/6/supporter "더 간단한"(그리고 주관적으로) 대신 http://stackoverflow.com/badges/6/.

내 사이트에서도 방금/게시/6/에 참조 게시물을 사용하여 게시물 (IDS에 의해 여전히 슬러그를 저장하더라도)을 사용했습니다. /post/6/small-rant-on-urls, 그리고 어떤 경우에는 더 터무니없는, 정말로 필요한 것보다 훨씬 더.

도움이 되었습니까?

해결책

Because you can potentially end up with duplicates if you're not careful. I imagine stack overflow added the ID because there was a high potential for duplicates given the volume of posts created.

Other systems may choose not to use the ID in the URL - for example, a blogging system probably would not need to.

It's a better idea if you have user generated content that results in a new URL created to include a post ID. If the only way new URL's can be created is through administrator type access, you can probably do without it as long as you check for duplicates.

다른 팁

Search Engine Optimisation would be one, as well as making the URL more readable to humans. Search engines generally like your URL, Title and H2 to contain the "topic" of the page.

If you have both in there then you can manually type /ID and get automagically taken to the "flowery" URL with rewriting.. saves your fingers a bit :)

Adding the slug in all links to the content helps with search engines, because search engines will generally use words in the URL itself to help index content.

The reason for including the id in the url is that it makes it easier behind the scenes to retrieve the correct article from the database, as a lookup can be performed on the ID rather than the article's title.

The reason for including the full title of the article, is that Google gives heaps of bonus points for search terms that are matched in the filename.

@Greg Hewgill

Adding the slug in all links to the content helps with search engines, because search engines will generally use words in the URL itself to help index content.

I should have clarified a bit: I meant URLs that have both an id and slug in them. I just don't see the point in having something like /post/1/la-la-la-la-text-hahahaha vs /post/1/ or /post/la-la-la-la-text-hahahaha, since the first one would work without the extranous text at the end.

URL is part of the Web user interface.

There is an eyetracking study of search engine use that found that people spend 24% of their gaze time looking at the URLs in the search results.

Searchers are particularly interested in the URL when they are assessing credibility and usefulness of a destination. If the URL looks like garbage, people are less likely to click on that search hit. On the other hand, if the URL looks like the page will address the user's question, they are more likely to click.

It could be that is faster to get the post in a blog by the id than by the slug, so put the id for the SQL query and the slug for the search engines (SEO).

https://stackoverflow.com/users/58163/movaxes65675

I like the /post/la-la-la-la-text-hahahaha type, i can remember the url, know what the title of the post is (before actually loading the site). Don't like much the /post/1/ it means nothing to me but post #1 (bad for marketing?)

edit: id also helps to avoid duplicates as andybaird pointed

Well, firstly it should be pointed out that the "Web 2.0 style URLs" are actually part of something called REST. Those URLs are sometimes called RESTful URLs. The claimed benefits are:

  • Provides improved response time and reduced server load due to its support for the caching of representations;
  • Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session;
  • Requires less client-side software to be written than other approaches, because a single browser can access any application and any resource;
  • Depends less on vendor software and mechanisms which layer additional messaging frameworks on top of HTTP;
  • Provides equivalent functionality when compared to alternative approaches to communication;
  • Does not require a separate resource discovery mechanism, due to the use of hyperlinks in representations;
  • Provides better long-term compatibility and evolvability characteristics than RPC. This is due to:
    • The capability of document types such as HTML to evolve without breaking backwards- or forwards-compatibility; and
    • The ability of resources to add support for new content types as they are defined without dropping or reducing support for older content types.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top