Error Pages In Yii

When my application throws an error it is properly showing the error pages as defined in my config/main.php. This is working as long as the URL starts with www.<mydomain>.com/index.php/ and anything which is within this URL throws the proper error message. E.g. https://www.<mydomain>.com/index.php/something throws an error since there is nothing to resolve "something".

My config/main.php looks like this.

However, if I have a URL looking like this:

https://www.<mydomain>.com/something -> This will show the default error pages used by IIS

http://www.<mydomain>.com/something -> This will show the default error pages used by IIS

Can I configure Yii in a way to include these paths too, or do I have to actually replace the default error pages used by IIS for these cases?

Does anyone know how to resolve this? Or perhaps the scope of Yii is only for pages from index.php and beyond, not for URL’s which end before?

Hi my friend

According to the server configuration, the request www.domain.com invokes index.php or index.html (if exist)

If the request is www.domain.com/index.php/somethinginvalidornot type, then Yii manipulates this and analyse the url parameters

but in the case of www.domain.com/somethinginvalidornot your server seeks for a folder except if you have another setting as it is described below

Yii framework (by your application) manipulates that by .htaccess. The default Yii code of this file is


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



Maybe in your server this file has not affect, did you check this issue?

I created a .htaccess file now with the code above and imported it in the “URL Rewrite” feature of IIS7.5. The rule has been created and applied, but it has only an effect on the first URL, so one step closer :)

How can I get the second URL covered (the one without https).

In addition to my comment above, I should add that I have disallowed usage of http on my site, so that when you try to go to a URL with http://something then it shows a 403 error message. This is not covered by either the URL rewrite rule or the Yii default configuration of error pages.

So my issue remain with URL’s which start with http:// instead of https:// . The first URL was solved by the rewrite rule suggested above, but not the second one.

I never used IIS but may this link helps you

How would you do it in Apache? I tried with this, but the last condition does not seem to work:

I created a lot of website with yii using Apache server without any similar issue!

The posted code .htaccess is the native of Yii.

Did you check it on Apache?

Also check it on localhost server (for example wampserver).

Please make I demo with simple php files and folders to reproduce the problem.

I thing the problem is with your server (or IIS).

I solved it by redirecting the servers default error 403-page to https://mysite . Maybe not the best solution, but since it only covers the root if someone types the URL incorrectly without HTTPS it should be enough for my case. That solved my second URL.

Many thanks for your help! :)

I think it would be nice if you combine some wiki on server configurations of IIS … I mean, how to re-interpret the .htaccess settings generally used in Yii for Apache. :)