Yii 404 Page - Override Parent Htaccess

I’m using the Yii framework at my company site.

I have a frontend at domain.com/… and a Yii based app at domain.com/app/… . We recently added a 404 page to the frontend site, with htaccess’s ErrorDocument handler at the frontend. Problem is, the Yii app inherits from that 404, which gives a bad page. How can I force it to use Yii’s embedded error handling page?

Thanks in advance.

Is your .htaccess similar to this:




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



From: http://www.yiiframework.com/doc/guide/1.1/it/topics.url

and also:

http://www.yiiframework.com/doc/guide/1.1/en/topics.error

Yes, this is my htaccess file at the frontend:


# Redirect non-www urls to www

RewriteEngine on


ErrorDocument 404 /404


RewriteCond %{HTTP_HOST} ^wisepricer\.com

RewriteRule (.*) <https link>$1 [R=301,L] # can't use links in posts as I'm a new member >_>

RewriteRule ^cart\-([\w\-_]+)$ carts-desc.php?cart=$1

RewriteRule ^([\w\-_]+)$ $1.php


AddType video/mp4  mp4 m4v

AddType audio/mp4  m4a

AddType video/ogg  ogv

AddType audio/ogg  ogg oga

AddType video/webm webm

Backend it’s pretty much blank except for my non-working attempt to add a second ErrorDocument:


ErrorDocument 404 /app/wpyii/index.php/site/error

You need to remove:




ErrorDocument 404 /404



Otherwise Apache will handle Error 404 page.

Naturally, but that’s my wanted behavior for the root. How can I override that for the Yii children directories only? The frontend should still have that 404 file.

Use RewriteEngine to handle 404 error code

and write before your handler for /app subfolder.

Similar this:




RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f

RewriteCond %{REQUEST_URI} ^/app

RewriteRule .* /404_yii.php

RewriteRule .* - [L]


RewriteCond %{REQUEST_FILENAME} -f

RewriteRule .* /404.php

RewriteRule .* - [F]