0

我在 php 文件中定义编码:

header("Content-Type:text/html;charset=utf-8");

现在我在我的模板文件中写了一个链接( smarty )

<a href="http://www.test.cn/maternal_and_child/lists/中文测试">Link</a>

顺便说一句,“中文测试”是中文的。但是当我点击链接时,它会返回如下错误:

The requested URL /maternal_and_child/app/webroot/lists/准备怀孕-优生优育 was not found on this server.

我该如何解决?

4

2 回答 2

4

http://www.test.cn/maternal_and_child/lists/中文测试不是有效的网址。您应该对网址进行编码:

http://www.test.cn/maternal_and_child/lists/%E4%B8%AD%E6%96%87%E6%B5%8B%E8%AF%95

于 2011-09-24T02:57:06.583 回答
1

使用 Smarty 对 URL 进行编码:

{* assuming the template variable $url holds your url *}
{$url|escape:'url'}

聪明的escape文档

于 2011-09-24T03:00:45.720 回答