URL 中的特殊字符
目前,我们正在将 URL 中的所有特殊字符和空格替换为连字符 (-)。 从搜索引擎优化和可读性的角度来看,这效果很好。 然而,在某些情况下,我们会在去掉连字符后将部分 URL 输入到搜索中。 当搜索词应该包含连字符时,就会出现问题,因为连字符被删除后不会返回任何结果。 我们可以修改我们正在使用的搜索算法,但这会减慢速度(尤其糟糕,因为我们将其与 AJAX 搜索框一起使用,并且这需要快)。
据我们所知,解决这个问题的最佳选择是用管道符 (|) 替换预先存在的连字符。 我有一种感觉,这将对这些术语的 SEO 产生负面影响,因为管道字符将被视为单词的一部分,而不是分隔符。 据我所知,唯一被视为分隔符的字符是连字符和正斜杠 (/)。
所以我的问题是:
- 我们可以使用其他字符来表示连字符吗?
- 如果我们不能使用任何其他字符,那么使用管道字符会对搜索引擎产生多大影响?
干杯, 扎克
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:
- Are there alternative characters we can use to represent hyphens?
- If we can't use any other characters, how much impact will using a pipe character have on a search engine?
Cheers,
Zac
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
~ (波浪线) 有效吗?
编辑:Google 现在将下划线和破折号视为单词分隔符,以便您可以使用破折号作为破折号,使用下划线作为空格。
Would ~ (tilde) work?
Edit: Google now treats underscores and dashes as word separators so you can use dashes as dashes and underscores as spaces.
为什么不使用 URL 编码? 大多数框架都内置了实用程序来执行此操作。
Why not use Url Encoding? Most frameworks have built in utilities to do this.
我本来想对 URL 编码说同样的话,但如果你想摆脱特殊字符,我想你不希望 URL 带有百分号,对吗?
改变“将部分 URL 输入到搜索中”的算法怎么样? 您不能添加一些逻辑来不替换 URL 搜索查询部分中的连字符吗?
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?