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?
To test, I removed all rewrite rules from the web server conf, and removed urlManager from main.php. Everything worked with the 'www.domain.com/index.php?r=' 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.
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) {
break;
}
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
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.