1. Front Office Unified Directory Management
The background management interface admin into the MyWeb directory, to achieve the foreground and background in the same directory, easy to manage and maintain.
Specific steps:
1. Copy and paste the/myweb/home directory into the/admin directory;
2. Modify the/admin/controller/indexcontroller.class.php file to change its namespace corresponding path from/home/controller to/admin/controller
3. At this point, you can access the background admin interface via the directory: Http://localhost/thinkphp/Index.php/Admin
Description: The index.php in the URL corresponds to the root directory of the application.
2. Modify Module access rights
Modify the/common/conf/config.php file.
2.1 No access: Module_deny_list
// ' Config item ' = ' config value ' // Disable module Access ' module_deny_list '=>array ('Common','Runtime', ' Admin")
This allows you to control the following directory access permissions
Since the common directory does not have an index file, the effect of accessing the common directory before the access is forbidden is the same.
Unable to load controller because index was not found
When access is forbidden, the effect of accessing the directory is this:
2.2 Allowed Access: module_allow_list
Note that when Module_allow_list is used, module_deny_list cannot be used at the same time. In addition, all modules outside the list will not be accessible after module_allow_list is used.
// module access is allowed, and modules outside the Allow_list range are inaccessible when this configuration is used. 'module_allow_list' = = Array ('Admin'),
2.3 Setting the default Access module
When more than one module in the system can be accessed, the default Access module can be set using default_module, note that this is not required to set in array mode. After Setup is complete, the corresponding module is set to load by default.
// Default_module as the default Access module ' Default_module '='Admin',
2.4 Setting a single entry for different modules
Copy and paste the index.php under the root directory as admin.php, and modify its contents.
// load Admin module $_get['m']='admin';
Once modified, you can access http://localhost/thinkphp/admin.php directly from the following URL:
Similarly, you can modify the configuration
2.5 Default Load Admin Controller
Modify the IndexController.class.php to AdminController.class.php and modify the content.
class Admincontroller extends Controller { public function Index () { ' Admin admin'; }}
Then, in the root directory of/admin.php, add the C parameter configuration
// Load Controller module $_get['C'Admin';
This way, the system loads the AdminController.class.php file in the \admin\controller directory, not the IndexController.class.php file.
3. URL operation mode
The URL operation mode of TP includes:
- PathInfo mode
- Normal mode
- Rewrite mode
- Compatibility mode
3.1PATHINFO mode:
/index.php/module/Controller/method name.
For example: Create UserController.class.php in the/home/controller directory, where controller is modified to:
class Usercontroller extends Controller { public function Index () { 'User Index'; }
Access to the following path allows access to the default index method: Http://localhost/thinkphp/index.php/Home/User
Wherein, method operation in the use of/method name/Parameter 1 name/parameter/parameter 2 name/Parameter way.
For example: module name: Home, Controllers: Controller, Method Name: Test, Parameter 1:user, parameters: Zhangsan parameter 2:password, parameters: 123
The corresponding code is as follows
Public function Test ($user, $password) { '$user'. $user.' <br/>password ' . $pass; }
The corresponding access connections are as follows:
Http://localhost/thinkphp/index.php/Home/User/test/user/zhangsan/pass/123
The results of the visit are as follows:
The default delimiter for the PathInfo mode is/. If you need to modify the delimiter, set the parameter in/common/conf/config.php URL_PATHINFO_DEPR
// delimiter Settings ' Url_pathinfo_depr '='_',
Http://localhost/thinkphp/index.php/Home_User_test_user_zhangsan_pass_123
3.2 Normal Mode
Http://localhost/thinkphp/index.php?m=Home&c=User&a=test&user=zhangsan&pass=123
where m represents the module, C represents the user, a represents the method, followed by the parameter name and parameters
In normal mode, the key value can be customized by Var_module, Var_controller, var_action three ways.
// ' url_pathinfo_depr ' = ' _ ', ' Var_module '= ' and 'mm', 'var_controller' ='cc', 'var_action' ='aa',
3.3 Rewrite mode
Open Apache's httpd.conf.
Thinkphp Learning-2: Modular Design