0

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?

1
  • Sorry,I know the 'test.cn' does exist, I want to know, why the character '中文测试' will change into '‡†å¤‡æ€€å­•-优生优育' Commented Sep 24, 2011 at 3:01

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

1

Encode the URL with Smarty by using:

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

Smarty escape docs

1 Comment

I try ( maternal_and_child/lists/?param=中文测试 ) then it work, but ( maternal_and_child/lists/中文测试 ) still don't work, And thank you, before it ,I use javascript to encode variable, now I know smarty have better one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.