我试图了解我应该如何URLs
使用URL
.
所以,类似Wikipedia
或Last.FM
网站。
我在网站上看到,用户可以写一些类似的东西http://it.wikipedia.org/wiki/Trentemøller
,并且可以访问艺术家的页面。
页面加载后,如果我复制我看到写为的 URL:http://it.wikipedia.org/wiki/Trentemøller
但如果我将其粘贴到文本编辑器中,它将被粘贴为
http://it.wikipedia.org/wiki/Trentem%C3%B8ller
所以charø
被粘贴为%C3%B8
当然,这样的 URL 也是如此(艺术家 Takeshi Kobayashi 的页面)
http://www.last.fm/music/小林武史
http://www.last.fm/music/%E5%B0%8F%E6%9E%97%E6%AD%A6%E5%8F%B2
如果我数字第一个或第二个,页面在任何情况下都有效,为什么?
.htacces
我想我应该对and做点什么,mod_rewrite
但我不确定,特殊字符是否会自动转换为 url 特殊字符?
然后,我该怎么做才能让 PHP 使用内容名称进行正确的查询?
如果我有一张像
table_users
- username
- age
- height
- weight
- sex
- email
- country
我可以mod_rewrite
写一个地址,比如http://mysite.com/user/bob
从那里得到username
鲍勃,table_users
但是呢http://mysite.com/user/小林武史
?
在这里,我展示了一个简单的示例来说明我的想法:
#.htaccess
RewriteEngine On
RewriteRule ^(user/)([a-zA-Z0-9_+-]+)([/]?)$ user.php?username=$2
<?php
// this is the page user.php
// this is the way I use to get the url value
print $_REQUEST["username"];
?>
这可行,但仅限于 [a-zA-Z0-9_+-],如何在不损失太多安全性的情况下像其他字符一样与所有字符更兼容?
有人知道一些避免麻烦的方法吗?