Special Characters in URL

こ雲淡風輕ζ 提交于 2019-12-23 20:03:08

问题


We're currently replacing all special characters and spaces in our URLs with hypens (-). From an SEO and readability point-of-view this works fine. However, in some cases, we are feeding parts of the URL into a search after stripping the hyphens out. The problem occurs when the search term should have hyphens as it returns no results when they get stripped. We could modify the search algorithm we're using but this will slow it down (especially bad as we're using it with an AJAX-ed search box and this needs to be fast).

The best option to deal with this, as far as we can tell is to replace pre-existing hyphens with pipes (|). I have a feeling that this will have a negative impact on SEO for those terms as the pipe character will be treated as a part of the word and not as a separator. As far as I can tell, the only characters that are considered to be separators are hyphens and forward slashes (/).

So my questions are:

  1. Are there alternative characters we can use to represent hyphens?
  2. If we can't use any other characters, how much impact will using a pipe character have on a search engine?

Cheers, Zac


回答1:


Would ~ (tilde) work?

Edit: Google now treats underscores and dashes as word separators so you can use dashes as dashes and underscores as spaces.




回答2:


Why not use Url Encoding? Most frameworks have built in utilities to do this.




回答3:


I was going to say the same thing about URL encoding, but if you're trying to get rid of the special characters, I suppose you don't want URLs with percent signs, right?

What about altering the algorithm that "feeds parts of the URL into a search"? Couldn't you add some logic to not replace hyphens within the search query part of the URL?



来源:https://stackoverflow.com/questions/270570/special-characters-in-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!