Modules and Routing

I can't get routing to work for modules.  I used yiic to build a module called main, then I put this in protected/config/main.php:




When I try to access I get 404 errors. 

The rewrite rule I have in my server conf basically takes the URI requested and appends it to index.php, which works for non-module controllers, but I think it should work for modules as well since the URI is just being appended.

I'm guessing I have to add a routing rule but where? And what would it look like?


Does or work?

To test, I removed all rewrite rules from the web server conf, and removed urlManager from main.php.  Everything worked with the '' syntax, even modules.

I then added back in the urlManager but without the showScriptName directive, and only the home page works.  The Contact page and Login page both give 404 errors.

The two URLs you asked about also return 404's.

That means you have some server configuration problem. Please show your .htaccess and $_SERVER array here when you access the default controller.

Also, do not define any URL rules yet. You just need to turn on the 'path' URL format.

I don't use .htaccess because I'm running under Nginx.

Anyway, I kept notes of all the rewrite rules I tried to get Yii working with Nginx (cookbook version included, which only resulted in 404's for any page but the home page at '/').  The one below is the second one I tried because it worked with CakePHP.  It did NOT work with Yii a day or two ago.

For whatever reason, plugging this same location block in now works for everything, including modules, and doesn't even require controller names in the location regex like I was doing.  I probably had a typo but had looked at it so long I couldn't see it.

With this, Yii works flawlessly:

        location / {

            root /var/www/html;

            index index.php;

            if (-f $request_filename) {



            if (!-e $request_filename) {

                rewrite ^/(.+)$ /index.php?url=$1 last;




With Nginx/FastCGI/php-fpm/Xcache/Yii the site is very, very fast even with no sysctl TCP tweaking and no distributed backends at the moment.

The only remaining issue with routing is returnURL.  When using it, 'index.php' still shows up even with showScriptName set to false.  Using homeURL does not show 'index.php'.

I'm assuming that should not happen with returnURL.