PHP rewrite rewrite settings (support Chinese parameters) _win Server in IIS Environment

Source: Internet
Author: User

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=}" Matchtype= "Isdirectory" negate= "true"/>
        </conditions>
       <action type= "Rewrite" url= "index.php" "/>
      </rule>
     </rules>
    </rewrite>
  </system.webServer>
</ Configuration>

cnurl.php:

<?php if (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 $_server[' request_uri '] = $_server[' http_x_re
Write_url ']; else {//use Orig_path_info if there 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 ' 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 the IIS environment to run a variety 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.