Reputation: 31
I have an image folder with all the user profile pics in the webroot.
Now I want to protect it with an htaccess file and options-indexes.
It works fine, but I want yii to redirect the user to my special forbidden view instead of showing this ugly 403 access denied apache site.
I tried the following code in my actionError
() in the Site Controller, but doesn't work.
if (Yii::app()->errorHandler->error['code'] == 403)
$this->redirect(Yii::app()->homeUrl);
Upvotes: 0
Views: 2122
Reputation: 3241
Assuming that the pictures are requested in a pattern like http://www.mydomain.com/pics/mypic.jpg yii is nowhere invoked so you can't achieve a redirection with the yii framework.
As @SuVeRa proposed on his comment you 'd better use the .htaccess to do the redirection e.g.
ErrorDocument 403 /dir/file.html
Upvotes: 1