Reputation: 486
I have a controller named CategoryAdminController.php
which can be accessed by {siteurl}/categoryadmin/index
in my localhost which is on a Windows machine. But when I try to launch it in my remote server which is on a Linux platform, it is unable to load the page. But when I rename my controller as CategoryadminController.php
(and the class name accordingly), it is working fine.
Is there any way to load the page while keeping the original name in the controller (ie: CategoryAdminController.php
)
According to Yii guide, seems it is not possible.
http://www.yiiframework.com/doc/guide/1.1/en/basics.convention
Any ideas?
Thank you
Upvotes: 1
Views: 1954
Reputation: 9556
To keep Controller names and Action names CamelCased and working on Linux, you need to add dash between each word in the URL:
"{siteurl}/category-admin/index" -> CategoryAdminController->indexAction()
"{siteurl}/category-admin/my-way" -> CategoryAdminControllern->myWayAction()
This will work both on Linux and Windows.
Windows reads files and folders case-insensitive. And often hides some of the mistakes.
The common issue comes when you develop on Windows ... and create a link categoryadmin
the OS will find be happy to give you a file like
CaTegoRYadmiNcontroller.php
ignoring the capitalization.
But when you deploy the same code and files on Linux you will get File Not Found
exceptions.
So, better stick to the convention.
Upvotes: 2
Reputation: 876
You can rewrite the URLs by using the urlManager. In your case you can use the following code:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => FALSE,
'rules' => array(
'categoryadmin/<action:\w+>' => 'categoryAdmin/<action>'
),
),
Upvotes: 0
Reputation: 16
It is case-sensitive for a file's name when on a Linux OS, but not on Windows. Did you try to access it: {siteurl}/categoryAdmin/index
?
Upvotes: 0