Shamrocker
Shamrocker

Reputation: 121

php url error code

I define encoding in php file:

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

Now I write a link in my template file ( smarty )

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

By the way, '中文测试' is chinese.But when I click the link, it return error like this:

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

How can I fix it?

Upvotes: 0

Views: 179

Answers (2)

Michael Berkowski
Michael Berkowski

Reputation: 270609

Encode the URL with Smarty by using:

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

Smarty escape docs

Upvotes: 1

zhongshu
zhongshu

Reputation: 7878

http://www.test.cn/maternal_and_child/lists/中文测试 is not a valid url. You should encode the url:

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

Upvotes: 4

Related Questions