【问题标题】:Need IIS rewrite rule for multiple WordPress in sub-directories or for WordPress multi-site virtual sub-directories to root directories需要为子目录中的多个 WordPress 或 WordPress 多站点虚拟子目录到根目录的 IIS 重写规则
【发布时间】:2020-06-11 19:01:20
【问题描述】:

我希望安装在根网站多个目录中的所有 WordPress 重写如下 例如:http://www.example.com/wordpress1/*http://www.example.com/wordpress2/*http://www.example.com/* 不包括 wp-admin 目录和所有。 管理员 URL 应与原始 URL 相同:http://www.example.com/wordpress1/wp-admin/ 我正在使用 IIS10。

或使用子目录选项重写 WordPress 多站点的规则,例如:http://www.example.com/wordpress1/* & http://www.example.com/wordpress2/*http://www.example.com/* 将适用于相同的豁免。

我将使用插件将类别转换为子域,所以如果我使用基于子域的 WP 多站点,那么将有 3 级域名。例如:http://category.subdomain.domain.com 但我希望它是第二级http://category.domain.com

目前我的网址是http://category.domain.com/subdomain 我想删除 /subdomain 部分。就是这样。

【问题讨论】:

标签: php wordpress iis web-config multisite


【解决方案1】:

请试试这个重写规则。该规则会将 http://www.example.com/wordpress1/* 和 http://www.example.com/wordpress2/* 重写为 http://www.example.com/* 并使用 wp-admin 排除 URL。

  <rule name="rewrite rule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{URL}" pattern="^/[^/]+/(.*)" />
                        <add input="{URL}" pattern="wp-admin" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}" />
                </rule>

【讨论】:

  • 当我把它放在 web.config 中时:403 - 禁止访问:访问被拒绝。当我将其放入 web.config 并将 Wordpress 网站网址更改为 www.example.com: 403 - Forbidden: Access is denied.
  • @Dipyan。您确定目标 URL 是您的预期 URL 吗?我的意思是你可以访问目标URL 可以直接访问吗?或者你的意思是你需要像friendlyURL这样的东西?
【解决方案2】:

我已经设法做到这一点,只需关注this tutorial 并添加一个条件函数,使用 $_SERVER 按域名重定向到确切的目录。

【讨论】:

    猜你喜欢
    • 2017-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    • 2021-07-16
    • 2018-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多