首页 > 解决方案 > 如何将 web.config 配置为 301 将所有 index.php 请求重定向到默认主页?

问题描述

我在运行 IIS 的 Windows 服务器上有客户的网站。我的一些客户以前的网站已编入索引,其中包括 index.php/varying_path_parameters

我想弄清楚的是如何修改 web.config 文件,以便对 index.php 文件的任何请求都重定向到主域。我有一个重定向来向任何 url 添加一个斜杠,但我不知道如何修改它以定位任何包含 .php 的请求

对 www.abc.com/index.php/someDir/ 的请求也是如此,我想将其重定向到 www.abc.com(不带斜杠)

如上所述,我已经有一个 web.config 文件,只是不确定如何重定向到主域

          <rule name="Add trailing slash" stopProcessing="true">
            <match url="(.*[^/])$" />
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
          </rule>

我只是希望将所有 .php 请求重定向到主域(请注意,我无法将 https : // 添加到消息中的 url,但我需要将其重定向到那里。

标签: iisweb-config

解决方案


推荐阅读