UrlManager delete pictures

Hi All.

While i was configuring the UrlManager, i saw that he is deleting my pics.

if i use:


'urlManager'=>array(

	'urlFormat'=>'path',

All my pictures are away and i see only a little broke symbol. If i comment out this line everything works fine.

What is this?

Do i have do configure more?

What you mean with pics? Pictures you serve by a controller-action?

For example the header.

got this:


<div id="header">

	<div id="logo"><?php echo CHtml::link(CHtml::image('images/stbg-logo-de.gif'), Yii::app()->request->baseUrl); ?></div>

</div><!-- header -->

while using the url format this is delete. i just only see the location. where it should be. but the image is not shown.

Then check out the source of the rendered html and see what output it produces (url of the images).

Also usually it’s best to put a slash before the relative image path:


/images/stbg-logo-de.gif


<div id="header"> 

	<div id="logo"><a href="/yii/stueh"><img src="/images/stbg-logo-de.gif" alt="" /></a></div> 

</div><!-- header -->

This is the sourcecode out of the HMTL. And it’s correct.

But the / before. Nothing happened. Still the failure, Can’t find Object.

Strange, and what if you rightclick on the broken image and select "display image"? Then it shows I guess??

I haven’t got the menupoint “display image” :blink:

if i try to open in new tab i get an 404 error.

do i also have to create actions for images? ???

Check your .htaccess:




# If a directory or a file exists, use it directly.


RewriteCond %{REQUEST_FILENAME} !-f


RewriteCond %{REQUEST_FILENAME} !-d





# Otherwise forward it to index.php.


RewriteRule . index.php



RewriteCond is mandatory.

Ok. Also have read something like this. but isn’t this also necessaray fo:


'showScriptName' => false,

And. Guys. Wehre the hell is the .htaccess or better, where do i have to put it.

DocumentRoot. OK. But where the hell is it?

my Directories look like that:

D:\xampp\htdocs\yii\porject1

and my projects went so on. project2 project3 etc.

so where i must put the .htaccess???

The hell advises to put it where your index.php resides.

nothing changed. :(

.htaccess should look like:




Options +FollowSymLinks

IndexIgnore */*

<IfModule mod_rewrite.c>

RewriteEngine on


# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php

RewriteRule . index.php

</IfModule



And, of course, Apache’s mod_rewrite should be enabled.

Maybe you need the base url.

If you entry script is something like localhost/yiiapp/index.php you have to explicity this base url with:




CHtml::link(CHtml::image( Yii::app()->request->baseUrl.'images/stbg-logo-de.gif')



Mine:


<?php echo CHtml::link(CHtml::image('/images/stbg-logo-de.gif'), Yii::app()->request->baseUrl); ?>

What’s the difference ???

The Module is on. Shall i change anything in my vhost conf?

First, check if rewrite module really works. Add some rules, e.g.:




RewriteRule ^test$ test.php



and then access http://site/test

Doesn’t work.

Btw i got an apache in xampp.

Shall i change anything in my view pages? work with CHttpRequest?

So your rewrite engine doesn’t work. I’m not familiar with xampp, so it’s the first link from Google: http://rudyegenias.wordpress.com/2006/08/21/enabling-mod-rewrite-in-xampp/

the modul was enabled. but the other point not. i have changed it. and suprise?!

nothing changed. :(

It’s possible that your .htaccess files are not used. It requires the AllowOverride setting in Apache for this directory to be set. You can also google this for more details.

looking for it.

found this:


<Directory "D:/xampp/cgi-bin">

    AllowOverride All

    Options None

    Order allow,deny

    Allow from all

</Directory>

and this:


<Directory />

    Options FollowSymLinks

    AllowOverride All

    Order deny,allow

    Deny from all

</Directory>

nothin’ changed