Simple example of php pseudo-static url rewriting

Source: Internet
Author: User
Simple example of php pseudo-static url rewriting

  1. RewriteEngine on
  2. RewriteRule ^ article/index.html $ article/index. php
  3. RewriteRule ^ article/detail-(. [0-9] * developer.html $ article/index. php? Type = detail & id = $1
  4. RewriteRule ^ article/list-(. [0-9] *)-(. [0-9] * ).html $ article/index. php? Type = list & classid = $1 & offset = $2
  5. RewriteRule ^ product/index.html $ product/index. php
  6. RewriteRule ^ product/detail-(. [0-9] * developer.html $ product/index. php? Type = detail & id = $1
  7. RewriteRule ^ product/list-(. [0-9] *)-(. [0-9] * 2.16.html $ product/index. php? Type = list & classid = $1 & offset = $2
  8. RewriteRule into index.html $ index. php
  9. RewriteRule ^ aboutus/detail-(. [0-9] * pai.html $ aboutus/index. php? Type = detail & id = $1
  10. RewriteRule ^ aboutus/detail-(. [0-9] *)-(. [0-9] * 2.16.html $ aboutus/index. php? Type = list & classid = $1 & offset = $2

Description: aboutus, article, and product are the module names.

  1. RewriteRule ^ aboutus/detail-(. [0-9] *)-(. [0-9] * 2.16.html $ aboutus/index. php? Type = list & classid = $1 & offset = $2

This is the page of The aboutus module. RewriteRule into index.html $ index. php is a homepage pseudo-static rewrite. if any module requires pseudo-static rewrite, refer to the preceding description in the. htaccess file.

2. go to System management on the website background-configuration management-change the pseudo-static module connection mode to 2. do not change other modules.

3. after rewriting the preceding address, you need to modify the link address, for example, the link address of the navigation, and use the link address of the first id of the aboutus module to write a static address, the above aboutus/detail -(. [0-9] * ).html, here (. [0-9] *) is changed to 1, modified to static address is so aboutus/detail-1.html can also be customized to add 1 link mode on it.

4. delete the cache, such as the article module. the address of the home page is still the article directory. you do not need to modify it. open the article module and check that the link to the article is static. Note: If the. htaccess file is stored in the root directory and the webpage cannot be opened, the deletion of the. htaccess website can be opened normally, probably because the environment does not support it.

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.