Urlmanager + Nginx

Hi all

The web server of an application that I maintain was moved from Apache to NGINX.

Everything is working perfectly, expcet the redirect to "loginUrl".

When the user is not logged and try to access www.appxyz.com, it should redirect to www.appxyz.com/site/login, but it is redirecting to www.appxyz.com/var/www/site/login, where "/var/www/" is the DocumentRoot.

After logged, everything works fine.

Is there any different configuration needed on the application side for using NGINX ?

Regards

Caio

There are a number of posts about nginx on the site; I suggest you do a search, perhaps your question has already been answered.

I’ve already searched and didn’t find any question about this kind of redirection.

And most of the questions due with server configuration and I don’t have any control about this.

Please post your urlManager rules in config/main.php to see if something can be done at the app level.


return array(

.

.

.

	'components' => array(

		'user' => array(

			'allowAutoLogin'=>true,

			'loginUrl' => array('site/login'),

			'class' => 'WebUser',

		),

		'urlManager' => array(

			'urlFormat' => 'path',

			'showScriptName' => false,

			'urlSuffix' => '/',

			'rules' => array(

				'search' => 'site/search',

				'<controller:\w+>/<id:\d+>' => '<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

				'<controller:\w+>/<action:\w+>' => '<controller>/<action>',

			),

		),

		

	),

.

.

.

);

There’s no rule to handle the case www.appxyz.com with no controller/action parameters. I would first try disabling the last 3 rules to see how it behaves; if that doesn’t work then add a rule to equate www.appxyz.com to site/login.

Thanks for your help, but It doesn’t work. :(

I don’t set any rule for “www.appxyz.com”, because it’s not necessary. It’s redirecting because the user is not logged.

After he is logged in the app, the urls rules work perfectly.

Remembering that this works just fine with Apache… the problem began when the hosting service changed for NGINX.

Sorry to hear that as I’m out of ideas; that’s why I started my replies suggesting changes to the nginx configuration. Take a look at the original .htaccess rules and if they were modified from the default perhaps you can make a case for having the nginx configuration changed. Good luck.