如何为 unicode 标题创建 unicode slug? [英] How to create unicode slug for unicode title?
本文介绍了如何为 unicode 标题创建 unicode slug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用 url 中的 unicode 字符清理博客标题.我需要用-"替换无效字符和空格,以便像这样更好地重写 seo.
I want to sanitize blog titles with unicode characters in url. I need to replace invalid characters and spaces with "-" for better seo rewriting like this.
http://example.com/это-моя-хорошая
谁能知道怎么做?
推荐答案
您可以将此算法用于 SEO 友好的 Unicode URL:
You can use this algorithm for an SEO-friendly Unicode URL:
- 将文本转换为 Unicode 规范化形式 C,即预组合字符.
- 使用带有 Unicode 字符类的正则表达式将每个非字母非数字字符替换为空格.
- 删除前导、尾随和双空格.
- 缩短.
- 用连字符替换空格.
这篇关于如何为 unicode 标题创建 unicode slug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文