Reputation: 3696
My site was working perfectly on localhost everything was going good. When I uploaded it to the live server it works just again except one controller (UserPersonalityController.php) All the controllers parsed and resolved perfectly except only one controller. Before you answer let me tell you that - My controller is uploaded (Not missing) - I have checked by changing route but it couldn't resolved the UserPersonalityController.
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
'signup' => 'Credentials/create',
'signup/<id:\d+>' => 'User/create',
'signup/lookingfor/<id:\d+>' => 'lookingfor/create',
'signup/personality/<id:\w+>' => 'UserPersonality/create',
//checked by commenting above line, still problem occurs
'people' => 'credentials/index',
'people/*' => 'Credentials/index',
....
Do you have any idea why this happens?
Upvotes: 1
Views: 1006
Reputation: 3696
I've now answer of my question. As I have came across with the problems for several days. My local is in windows where files and directories are not case sensitive that's why it was working just fine. When I uploaded my site to the server (linux) it treats all file names and directories as case sensitive.
So controller UserPersonalityController was not same as UserpersonalityController because of the configuration of url manager in app.
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false, //
The simple solution to the problem is to keep lower case names of controllers.
UserPersonalityController.php
UserpersonalityController.php
//Both above files are treated as completely different ones on linux while on windows
//they are same files.
Note Never capitalize any letter between controller names. First letter and letter C of controller must be capital. In between never keep any letter capital as you may run into problems. There might be other solutions to the problem. But I've solved by changing file names to lower case.
Further Reading: http://www.yiiframework.com/forum/index.php/topic/651-controller-file-name-case-sensitive/
Upvotes: 1
Reputation: 7647
For Url Management to work, first apache has to pass the url to yii only then yii can run the corresponding controller/action . Normally apache would process these urls as directories, and try to find corresponding files in these locations You can create .htaccess file like this and place it in your root directory,
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
Note: For this to work you need to have rewrite engine enabled in apache config You can do so with the following set of commands In order to use mod_rewrite you can type the following command in the terminal:
a2enmod rewrite
Restart apache2 after
/etc/init.d/apache2 restart
or
service apache2 restart // (Ubuntu/Debian)
Upvotes: 1