First enable the Mod_rewrite module (varies by operating system, current Linux)
1,apache Enabling the Mod_rewrite module
Editor:/etc/apache2/httpd.conf
Uncomment: LoadModule rewrite_module/usr/lib/apache2/modules/mod_rewrite.so
2, select Directory to change allowoverride None to allowoverride all.
3, restart Apache
The project root creates a file. htaccess the request to the public directory (adjusted on demand)
1
2 Rewriteengine on
3 Rewriterule ^$ public/[L]
4 Rewriterule (. *) public/$1 [L]
5
Finally, turn the request to the public/index.php file (where all requests are distributed)
1
2 Rewriteengine on
3
4 Rewritecond%{request_filename}!-f
5 Rewritecond%{request_filename}!-d
6
7 Rewriterule ^ (. *) $ index.php?url=$1 [pt,l]
8
9
app->public->index.php
This can achieve a single portal of the site, but also the beginning of the MVC pattern, the next step you can try to distribute our URL for the three part of controller/action/querystring ....
Excerpted from Warcraft
http://www.bkjia.com/PHPjc/478226.html www.bkjia.com true http://www.bkjia.com/PHPjc/478226.html techarticle first enable the Mod_rewrite module (adjusted by operating system, current Linux) 1,apache enable mod_rewrite module editing:/etc/apache2/httpd.conf uncomment: LoadModule Rewrit ...