PHP rewrite override settings (support for Chinese parameter) instances under IIS

Source: Internet
Author: User

The PHP rewrite settings in the IIS environment support Chinese parameters.

In the site root directory, add:
Web. config:

<?xml version= "1.0" encoding= "utf-8″?><configuration><system. Webserver><rewrite><rules><rule name= "Cnurl" stopprocessing= "true" ><match url= "!^ (index\ . Php|images|assets|robots\.txt) "/><action type=" Rewrite "url=" cnurl.php "/></rule><rule name=" Default "patternsyntax=" Wildcard "><match url=" * "/><conditions><add input=" {request_filename} " Matchtype= "Isfile" negate= "true"/><add input= "{request_filename}" matchtype= "Isdirectory" negate= "true"/> </conditions><action type= "Rewrite" url= "index.php"/></rule></rules></rewrite>< /system.webserver></configuration>Cnurl. php:<?PHPif(isset($_server[' Http_x_original_url '])) {//IIS Mod-rewrite$_server[' request_uri '] =$_server[' Http_x_original_url '];} Else if(isset($_server[' Http_x_rewrite_url '])) {//IIS isapi_rewrite www.jbxue.com$_server[' request_uri '] =$_server[' Http_x_rewrite_url '];} Else {//Use Orig_path_info If there is no path_info(!isset($_server[' Path_info ']) &&isset($_server[' Orig_path_info '])) && ($_server[' path_info '] =$_server[' Orig_path_info ']);//Some IIS + PHP configurations puts the script-name in the Path-info (No need to append it twice)if(isset($_server[' Path_info '])) {($_server[' path_info '] = =$_server[' Script_name ']) ? ($_server[' request_uri '] =$_server[' Path_info ']) : ($_server[' request_uri '] =$_server[' Script_name '].$_server[' Path_info ']);}//Append The query string if it exists and isn ' t null(isset($_server[' Query_string ']) &&!Empty($_server[' query_string '])) && ($_server[' Request_uri ']. = '? ' .$_server[' Query_string ']);}require("index.php");

Support IIS environment to run all kinds of open source PHP projects, such as: Wordpress, Emlog, Typecho and so on.

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.