网址友好的安全字符 [英] Safe characters for friendly url

查看:74
本文介绍了网址友好的安全字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个包含文章的网站,并且我想为其提供友好的URL,例如带有

的页面的URL

标题:文章测试

应变为:http://www.example.com/articles/article_test.

我当然需要从标题中删除某些字符,例如?#,但是我不确定要删除哪些字符.

有人可以告诉我哪些字符可以安全保存吗?

解决方案

引用 RFC 3986 :

"URI中允许但没有保留的字符 目的被称为无保留.这些包括大写和小写 字母,十进制数字,连字符,句号,下划线和波浪号."

ALPHA  DIGIT  "-" / "." / "_" / "~"

请注意,RFC 3986列出的保留标点符号比旧的 RFC 2396 少. /p>

I need to make a website that will have articles, and I would like to make friendly URLs for it, example the URL of the page with

Title: Article Test

should become: http://www.example.com/articles/article_test.

Of course I need to remove some characters from the title like ? or #, but I'm not sure which ones to remove.

Can someone tell me what characters are safe to keep?

解决方案

To quote section 2.3 of RFC 3986:

"Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde."

ALPHA  DIGIT  "-" / "." / "_" / "~"

Note that RFC 3986 lists fewer reserved punctuation marks than the older RFC 2396.

这篇关于网址友好的安全字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆