【问题标题】:URL Rewrite - ISAPIURL 重写 - ISAPI
【发布时间】:2017-07-12 06:54:59
【问题描述】:

我将这个 URL http://www.example.com/controlpanel/index.php 改写为以下内容: http://www.example.com/

意思是,我需要以某种方式摆脱“控制面板”部分并强制 index.php 解析为 root。

我正在运行 Win Server 2016 和 IIS 10.0。

谢谢

【问题讨论】:

  • 您为什么要询问 ISAPI?自 IIS 7 起,IIS 就有一个托管管道 URL 重写模块。
  • 好吧,因为这个 PHP 应用程序建议我应该使用“Apache mod_rewrite”或“Isapi rewrite”。谢谢
  • 请注意,PHP 的 IIS 文档非常非常过时(它仍然指的是 IIS6,它是 Windows Server 2003 的一部分 - IIS7 完全不同,它是在 2006 年与 Windows Vista 和 Server 一起发布的2008)。
  • 当然可以。顺便说一句,即使这意味着使用 URL 重写,你能帮我解决这个问题吗?谢谢
  • 您是否在网上查找过 IIS URL 重写文档?

标签: php regex windows iis url-rewriting


【解决方案1】:

你需要做什么:

  1. 安装IIS URL rewrite module
  2. 使用此内容创建 web.config 文件:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="rewrite sample" stopProcessing="true">
                    <match url="^$" />           
                    <action type="Rewrite" url="/controlpanel/index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

如果您已经有 web.config 文件,只需添加我的rule

此规则会将您的主页http://www.example.com/ 重写为 http://www.example.com/controlpanel/index.php

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-10
  • 2010-11-09
相关资源
最近更新 更多