On Windows Server, use the IIS rewrite component to set a pseudo-static method for IIS

Source: Internet
Author: User
1. Extract the downloaded IIS rewrite component to the appropriate directory (such as C: rewrite), IIS rewrite component download http://www.helicontech.com/download-isapi_rewrite.htm, IIS rewrite simplified component download http://www.newhua.com/soft/71446.htm, download and decompress the package.

1. Extract the downloaded IIS rewrite component and put it in the appropriate directory (such as C: rewrite). Download the IIS rewrite component to download the http://www.helicontech.com/download-isapi_rewrite.htm,IIS rewrite simplified component.

Note:Introduction to IIS rewrite: A Powerful URL Processing Engine with similar functions as mod_rewrite in Apache. This is a list. asp? The link id = 234 is mapped to list/234.html, which facilitates ranking in GG.

The biggest difference between full and Lite is that each site can customize the URL rewriting rule (rewrite rule), that is, as long as the httpd is written. you can use ini in the root directory of the site.

Installation instructions: After downloading, You can decompress isapi_rewrite.dll and httpd. INI files are placed under a folder, and then isapi_rewrite.dll can be loaded in the ISAPI of the IIS Site attribute, httpd. INI is an example in the configuration file. If the load fails, set the isapi_rewrite.dll Security Attribute to complete.



2. In "IIS manager", right-click the website and choose Properties.

 

3. Select "ISAPI" and click "add ".



4. Enter the Filter Name, for example, "Rewrite ".

 

5. Click "Browse" at the bottom of the executable file, and select the location of the extracted rewrite component, rewrite. dll.

 
6. Confirm the selection and click "OK ".

7. Click "OK" to add the filter.

8. Restart IIS.

 

9. After IIS is restarted, right-click the site and choose properties. The Green Arrow shown below indicates that IIS rewrite is successfully added and run.

 

IIS rewrite rule settings

In the decompressed IIS rewrite component directory (such as C: rewrite), there is an httpd. ini file that writes the corresponding rules to this file.

1. Install the rewrite plug-in rewrite. dll

If your IIS server has loaded rewrite. dll, you do not need to download it.

Rewrite. dll file: Baidu search keyword: rewrite. dll download

Load rewrite. dll

Add filter on IIS ISAPI

Filter Name: Re

Select rewrite. DLL for the executable file!

2. Configure httpd. ini
Open your httpd. ini and find

[Isapi_rewrite]

#3600 = 1 hour
Cacheclockrate 3600

Repeatlimit 32

# Protect httpd. ini and httpd. parse. Errors files
# From Accessing through HTTP
Rewriterule ^ (. *)/archiver/([a-z0-9-]+.html) $1/archiver/index. php? $2
Rewriterule ^ (. *)/forum-(%0-9%%*-(%0-9%%%%%%%.html $1/Forumdisplay. php? FID = $2 & page = $3
Rewriterule ^ (. *)/thread-(0-9000000000000-(0-9000000000000-(0-90000000000000000.html $1/viewthread. php? Tid = $2 & extra = Page % 3d $4 & page = $3
Rewriterule ^ (. *)/profile-(username | UID)-(. + ?). HTML $1/viewpro. php? $2 = $3

The above is discuz! The configuration code officially provided. Pay attention to the regular format.

3. Application
For example, read. php? Bl_id = 123 & bu_id = 456 pseudo-static/html/123/456 .html

You can write as follows:

Rewriterule ^ (. *)/html/([0-9] +)/(%0-9%%%%%%.html $1/read. php? Bl_id = $2 & bu_id = $3

To enable your IIS server to support pseudo-static rewriting, follow these steps:

1. Install the rewrite plug-in rewrite. dll

If your IIS server has loaded rewrite. dll, you do not need to download it.

Load rewrite. dll

Add filter on IIS ISAPI

Filter Name: Re

Select rewrite. DLL for the executable file!

2. Configure httpd. ini
Open your httpd. ini and find

[Isapi_rewrite]

#3600 = 1 hour
Cacheclockrate 3600

Repeatlimit 32

# Protect httpd. ini and httpd. parse. Errors files
# From Accessing through HTTP
Rewriterule ^ (. *)/archiver/([a-z0-9-]+.html) $1/archiver/index. php? $2
Rewriterule ^ (. *)/forum-(%0-9%%*-(%0-9%%%%%%%.html $1/Forumdisplay. php? FID = $2 & page = $3
Rewriterule ^ (. *)/thread-(0-9000000000000-(0-9000000000000-(0-90000000000000000.html $1/viewthread. php? Tid = $2 & extra = Page % 3d $4 & page = $3
Rewriterule ^ (. *)/profile-(username | UID)-(. + ?). HTML $1/viewpro. php? $2 = $3

The above is discuz! The configuration code officially provided. Pay attention to the regular format.

3. Application
For example, read. php? Bl_id = 123 & bu_id = 456 pseudo-static/html/123/456 .html

You can write as follows:

Rewriterule ^ (. *)/html/([0-9] +)/(%0-9%%%%%%.html $1/read. php? Bl_id = $2 & bu_id = $3

Another example:

123. php? Id = 123
123, ID, 123
Rewriterule ^ 123/ID/([0-9] [0-9] [0-9])/$/123.php? Id = $1
Or
Rewriterule ^ 123/ID/([0-9] +) $/123.php? Id = $1

PW rules: [isapi_rewrite]
Rewriterule ^ (. *)-HTM-(. *) $ 1.php? $2
Rewriterule ^ (. *)/simple/([a-z0-9_]+.html) $1/simple/index. php? $2

Note: For example, the pseudo-static settings in interactive encyclopedia are similar to those in the setting method. The pseudo-static settings in other systems are similar, the possible difference is that the pseudo-static rule settings are different.

Personal remarks:

$1, $2, and $3 are the matching values of the previous expression.

For example:

^ (. *)/Simple/([a-z0-9_]+.html) $1/simple/index. php? $2

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.