Search code examples
character-encodinghyperlinkyiianchorurl-encoding

Yii framework CHtml::link error jump to a named anchor in another page


I'm use Yii Framework.

I have a named anchor <a name="projet">projet</a> in about.php page. I've created a link in the index page to the named anchor in the about page like that :

     <?php  echo CHtml::link('MyLink',array('site/page','view'=>'about#projet')); ?>

But when I click on the link "MyLink", I have an error 404 response with this message :

     The requested view "about#projet" was not found.

And in the url I have:

     localhost/myApps/index.php?r=site/page&view=about%23projet

I checked default charset application is UTF-8. So I don't understand why my link isn't well encoded. Someone can help me please?


Solution

  • try this:

    echo CHtml::link('MyLink',array('site/page','view'=>'about', '#'=>'projet'));