Configure HTTP. conf in Apache
# Make PHP look like other programming languages, use PHP to parse files with the following extensions
Addtype application/X-httpd-PHP. asp. py. pl. html. htm
Or set php as the default file.
HTTP. conf-Apache
# Set default file type to PhP
Defaulttype application/X-httpd-PHP
Then configure in PHP. ini-PHP to hide the PHP suffix.
Expose_php = off
And the PHP file is also written as a non-suffix file.
Your URL is www.domain.com/test? Key = Value
The URL configured with addtype above is long as www.domain.com/test.html? Key = Value
Another method is to use index. php In the code to hide the PHP suffix and route it to the corresponding module. The principle is to intercept $ _ server [quert_string] and parse it,
Then include the corresponding module
The result is as follows:
Www.domain.com /? Article/ID/54/type/News & cat = 2
The original URL should be like this.
Www.domain.com/modul_directory/article.php? Id = 54 & type = News & cat = 2
Index. php
--------------
<? PHP
// Parsing query string
$ Qs = explode ("&", $ _ server ['query _ string']);
$ Qs = explode ('/', $ QS [0]);
// If modul is undefined set it to index
If (! $ QS [0]) $ modul = 'index ';
Else $ modul = strtolower ($ QS [0]);
// We can make a variable $ _ Query
// For alternative _ Get
For ($ I = 1; $ I <count ($ QS); $ I + = 2)
{
$ _ Query [$ nvar] = $ nvar = $ QS [$ I];
$ Nvar = $ QS [$ I + 1];
}
// Check the modul is exists?
If (! File_exists ("modul_directory/{$ modul}. php "))
$ Modul = "Index ";
#### This is example
Implementation The Script
// Load the Template
Include ("template. php ");
// Load the module
Include ("modul_directory/{$ modul}. php ");
// Load
Footer
Include ("footer. php ");
?>