Home > Article > Backend Development > Configuring .htaccess single point of entry_PHP tutorial
First enable the mod_rewrite module (adjust according to different operating systems, currently Linux)
1. Apache enables Mod_rewrite module
Edit: /etc/apache2/httpd.conf
Uncomment: LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
2. Select Directory and change AllowOverride None to AllowOverride All.
3. Restart Apache
Create a file .htaccess in the project root directory and redirect the request to the public directory (adjust as needed)
1
2 RewriteEngine on
3 RewriteRule ^$ public/ [L]
4 RewriteRule (.*) public/$1 [L]
5
Finally, forward the request to the public/index.php file, (distribute all requests here)
1
2 RewriteEngineOn
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 entrance to a website and is also the starting point of the MVC model. The next step can be to try to distribute our url as three parts controller/action/querystring.....
Excerpted from warcraft