Yii 1.1: baseurlappender

ViewRenderer which will append baseurl to urls and links in the rendered view

Are you tired of prepending Yii::app()->request->baseUrl to each image SRC attribute, script or CSS file source link?

Just install this simple extension and it will append baseurl for you.



  • Yii 1.0 or above


  • Extract the release file under protected/extensions


Edit your main layout file (usually /protected/views/layout/main.php)

<?php $this->beginWidget('application.extensions.BaseUrlAppender') ?>
<?php $this->endWidget() ?>

now all refernces like

<img src='/images/image.png'/>

and others will be rewritten to

<img src='/path/to/application/images/image.png'/>

List of all rewritten tags:


Change Log

February 26, 2009

  • Initial release.

February 27, 2009

  • version 1.1
  • Rewritten as CWidget, documentation changed

Total 2 comments

#1215 report it
oleksiy at 2009/10/22 05:17am
2 HTML alternative

Because some people would prefer not to depend on some broken search bots which ignore base href, broken browsers which prepend base href where it should not be prepended, etc.

#1216 report it
Blake-R at 2009/10/22 03:51am
HTML alternative

Wherewith is bad to use '' meta tag?

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: oleksiy
  • Category: Others
  • Votes: +1 / -1
  • Downloaded: 832 times
  • Created on: Feb 26, 2009
  • Last updated: Feb 27, 2009