Configure the. htaccess single point of access

Source: Internet
Author: User
First, enable the mod_rewrite module (adjusted according to the operating system, current linux) 1. enable the Mod_rewrite module in Apache:/etc/apache2/httpd. conf uncomment: LoadModulerewrite_module/usr/lib/apache2/modules/mod_rewrite.so2 ,.

First, enable the mod_rewrite module (adjusted according to the operating system, the current linux)
1. Apache enables the 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 in the project root directory. htaccess redirects the request to the public directory (adjusted as needed)
1
2 RewriteEngine on
3 RewriteRule ^ $ public/[L]
4 RewriteRule (. *) public/$1 [L]
5
 
Finally, redirect the request to the public/index. php file (distribute all requests here)
 
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
In this way, we can implement a single portal for a website, which is also the starting point of the MVC mode. next we can try to distribute our url to three parts: controller/action/querystring .....

 


From warcraft

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.