You may often see this path on the Internet (http://www.aaa.com/aaa/bbb/aaa? Id = 5), confusing. There are several possibilities to implement such a website: 1. expand the name of a hidden file, but I personally feel that no one may often see such a path on the Internet (http://www.aaa.com/aaa/bbb/aaa? Id = 5), confusing. There are several possibilities for implementing such a website:
1. the expanded names of hidden files have all said about the benefits of such practices, but I feel unnecessary;
2. use website redirection rules to implement virtual paths;
3. implement virtual paths by forcing file resolution.
2nd \ 3 methods can be used to implement the same interface of the website, integrate the website fairly, and better reflect the security and architecture of the website, most websites using these two methods are built and implemented using the 'mvc 'mode.
The following is an example.
The visit path is as follows:
.../Test/******/Bad
.../Test/******/Good
(The '*******' can be replaced with any string. '...' is your web path)
The directory structure of the file is as follows:
| --. Htaccess
| -- Test
| -- Application. php
| -- Controler/GoodControler. php
| -- Controler/BadControler. php
Note that the file '. htaccess' cannot be directly created in windows. it can be created in command line mode.
File 0 (. htaccess) (This file is used to change the apache configuration method)
Forcetype application/x-httpd-php
File 1 (test. php)
/*-------------------------------------
* Test. php
*
* Imported files for your website
* Used for initialization and import
* Call the call to fulfill the Controler
*
-------------------------------------*/
Require 'application. php ';
$ Aa = new Application ();
$ Aa-> parse ();
$ Aa-> go ();
?>
File 2 (GoodControler. php)
/*-------------------------------------
* GoodControler. php
*
* Used to hold visits from url =/test/Good
*
-------------------------------------*/
Class GoodControler {
/*
* The call method of the control class, which is unique for reporting to external interfaces
*/
Function control (){
Echo 'This is from GoodControler url = *********/test/good ';
}
}
?>
File 3 (BadControler. php)
/*-------------------------------------
* BadControler. php
*
* Used to hold visits from url =/test/Bad
*
-------------------------------------*/
Class BadControler {
/*
* The call method of the control class, which is unique for reporting to external interfaces
*/
Function control (){
Echo 'This is from GoodControler url = *********/test/bad ';
}
}
?>
File 4 (Application. php)
/*-------------------------------------
* Application. php
*
* The Controler class is called to implement the same import of a website.
*
-------------------------------------*/
Class Application {
// Used to record the desired hold
Var $ action;
// Name of the controler file
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service