IIS环境下PHPrewrite重写设置(支持中文参数)
2023-06-13 09:15:32 时间
在网站根目录下加入:
Web.Config:
<?xmlversion="1.0"encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <rulename="cnUrl"stopProcessing="true"> <matchurl="!^(index\.php|images|assets|robots\.txt)"/> <actiontype="Rewrite"url="cnurl.php"/> </rule> <rulename="Default"patternSyntax="Wildcard"> <matchurl="*"/> <conditions> <addinput="{REQUEST_FILENAME}"matchType="IsFile"negate="true"/> <addinput="{REQUEST_FILENAME}"matchType="IsDirectory"negate="true"/> </conditions> <actiontype="Rewrite"url="index.php"/> </rule> </rules> </rewrite> </system.webServer> </configuration>
cnurl.php:
<?php if(isset($_SERVER["HTTP_X_ORIGINAL_URL"])){ //IISMod-Rewrite $_SERVER["REQUEST_URI"]=$_SERVER["HTTP_X_ORIGINAL_URL"]; }elseif(isset($_SERVER["HTTP_X_REWRITE_URL"])){ //IISIsapi_Rewrite $_SERVER["REQUEST_URI"]=$_SERVER["HTTP_X_REWRITE_URL"]; }else{ //UseORIG_PATH_INFOifthereisnoPATH_INFO (!isset($_SERVER["PATH_INFO"])&&isset($_SERVER["ORIG_PATH_INFO"]))&&($_SERVER["PATH_INFO"]=$_SERVER["ORIG_PATH_INFO"]); //SomeIIS+PHPconfigurationsputsthescript-nameinthepath-info(Noneedtoappendittwice) 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"]); } //Appendthequerystringifitexistsandisn"tnull (isset($_SERVER["QUERY_STRING"])&&!empty($_SERVER["QUERY_STRING"]))&&($_SERVER["REQUEST_URI"].="?".$_SERVER["QUERY_STRING"]); } require("index.php");
支持IIS环境下跑各种开源PHP项目,如:Wordpress、Emlog、Typecho等。
相关文章
- AutoCAD 2023最新中文注册版「win/mac」
- linux系统下codeblocks控制台打印中文乱码[通俗易懂]
- pytest skipif_skip的中文是什么
- Navicat Premium 16 for Mac(数据库管理软件)v16.1.3中文激活版
- Mac/win Rhinoceros 7 (犀牛)中文特别版
- 排版软件Id下载:InDesign 2023中文版本安装激活教程 --干货分享
- InCopy(Ic)2022软件下载 IC中文直装版下载 最新版Win/Mac附安装包
- Oracle实现中文正则表达式匹配(oracle匹配中文)
- SQL Server存储中文的优势与诀窍(sqlserver存中文)
- MySQL中文乱码问题如何解决中文字符变成问号(mysql中中文变成问号)
- PHP中文分词自动获取关键词介绍
- jsunicode编码解析关于数据转换为中文的两种方法