This article describes how to solve the url case-sensitivity problem in the zendframework framework, including the case sensitivity of the action Controller and request URL, anyone who needs it can refer to anyone who has used the Zend Framework to develop projects knows that the Controller and Action names in Zend Framework (ZF) MVC do not support case sensitivity by default, this is obviously unacceptable for developers who are used to camper code. Fortunately, you can set the useCaseSensitiveActions parameter of the front-end Controller FrontController to name Zend Framework controllers and actions in case. the code is as follows:
The code is as follows:
$ Front = Zend_Controller_Front: getInstance ();
$ Front-> setParam ('usecasesensitiveactions ', true );
If an Action is defined in AppController as CoderBolgAction (), http: // localhost/app/coder-bolg/is required for the URL to access this Action /, note that '-' is added before the second uppercase letter of Action '-'. This is okay, at least the problem is solved, and the addition of '-' does not affect SEO, or even more friendly than the camper type for search engines. However, there is a more intolerable problem: The URL is also case sensitive. That is to say, if a user enters a letter of Action in the URL, it cannot be displayed. Dizzy ......, However, this is a better solution. Modify ModuleName, ControllerName, and ActionName to lowercase before routing. In the init () method of Zend_Controller_Action, I add these three lines to the init () method:
The code is as follows:
$ This-> _ request-> setModuleName (strtolower ($ this-> _ request-> getModuleName ()));
$ This-> _ request-> setControllerName (strtolower ($ this-> _ request-> getControllerName ()));
$ This-> _ request-> setActionName (strtolower ($ this-> _ request-> getActionName ()));
In this way, the URL is case sensitive.