PHP set pseudo-static

Source: Internet
Author: User

1. First check to see if the server supports pseudo-static.

To view the method:

$arr =apache_get_modules ();
$temp =false;
for ($i =0; $i <count ($arr); $i + +)
{
I f ($arr [$i]== "Mod_rewrite")
{
$temp =true;
}
If Temp=true is supported (can be enabled to display on the Web page), if the WAMP integration environment can be directly see the Apache modules inside the rewrite modules is checked, check support,

2. Let Apache server support. htaccess

Modify the httpd.conf file

Options FollowSymLinks
AllowOverride None
Switch
Options FollowSymLinks
AllowOverride All



After this step is set up, you will have to restart the Apache server to take effect.

3. After the modification is pseudo-static support, build a. htaccess file, which records the pseudo-static rules, examples are as follows:

Rewriteengine on #这句话必须写
#RewriteRule ([A-za-z]{1,})-([0-9]{1,}) \.html$ index.php?action=$1&id=$2

Rewriterule ^ ([0-9]+). html$ list.php?catid=$1 #定义的规则
#list. php?id=1801
#1801. html

Rewriterule ^ ([0-9]+)-([a-za-z_]+). html$ list.php?catid=$1&sort=$2
#list. Php?catid=1801&sort=price_desc
#50010788-price_desc.html

Rewriterule ^ ([0-9]+)-([0-9]+). html$ list.php?catid=$1&page=$2
#list. php?catid=1801&page=2
Rewriterule ^ ([0-9]+)-([a-za-z_]+)-([0-9]). html$ list.php?catid=$1&sort=$2&page=$3
#RewriteRule ([0-9]+)-([a-za-z_]+)-([0-9]+). html$ list.php?catid=$1&sort=$2&page=$3
#list. php?catid=50010788&sort=price_desc&page=2
#50010788-price_desc-2.html

3. Enter 1801.html in the corresponding directory of the website is the equivalent of input? id=1801


This article is from "Buffy Rain Blog" blog, please be sure to keep this source http://bafeiyu.blog.51cto.com/5401101/1602462

PHP set pseudo-static

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.