【问题标题】:Wordpress permalinks on IIS?IIS 上的 Wordpress 永久链接?
【发布时间】:2017-07-13 12:56:43
【问题描述】:

我在 Windows 7 IIS 上使用 WordPress 进行开发。我在 WordPress 中为博客文章上传图片。图片在网站上显示正常,但一旦我启用永久链接,图片就不再起作用,以后上传的任何图片都会返回一个错误:

HTTP Error 500.50 - URL Rewrite Module Error.
The page cannot be displayed because an internal server error has occurred.

我不知道为什么会这样,这是我的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="wordpress" patternSyntax="Wildcard">
          <match url="*" />
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

一旦我关闭我的永久链接并使用它的默认设置,有人知道为什么会这样吗?

【问题讨论】:

  • 非常感谢这对我有帮助!到处寻找 url 重写问题

标签: wordpress iis-7


【解决方案1】:

图片问题是权限问题,只是手动设置 对原始图像文件或父文件夹是不够的。这 WordPress 的行为是它使用 IUSR 写入原始文件 到 PHP.ini 文件中定义的临时系统目录。 这个临时文件夹没有 IIS_IUSRS 权限,所以当 windows 将此文件从临时文件夹移动到应用程序的 上传文件夹,它的最终home,IIS_IUSRS只有读权限,所以 权限不是从文件的父文件夹继承的。

要解决此问题,有两种解决方案。

  1. 更改临时文件夹的权限,授予 IIS_IUSRS 写入/修改权限。
  2. 将 PHP.ini 文件中临时文件夹的路径更改为具有 IIS_IUSRS 写入/修改权限的文件夹。

这是一个详细说明问题的好来源: http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/

我选择将 PHP.ini 中的临时文件夹移动到 C:\inetpub\temp\uploads 并授予它权限。上传后 wp-admin 中的图像,我能够访问图像(原始,不是 调整大小)从没有 500.50 错误的浏览器。

From source

【讨论】:

  • 不会修复已上传的文件,但 C:\inetpub\temp\uploads 技巧效果很好。请务必在 inetpub\temp\uploads 上设置正确的权限。更改 php.ini 并重新启动 Web 服务器后,所有新的媒体库上传不再获得 500.50。
【解决方案2】:

Using Permalinks « WordPress Codex 处的 web.config 略有不同,在 Windows 上没有 mod 重写的永久链接还有其他选项。

【讨论】:

  • 嗨 songdogtech,感谢您的链接。那是我一直在关注的文档,我重试了,但仍然没有运气:/您还有其他建议吗?
  • 没关系,我修好了。原来 IIS 没有权限,我跟着这个:tech-problems.com/… 它工作得很好!
  • 我认为 WordPress 的 codex 是错误的。 @JeffTaggarty 为我工作的web.config 对我有用,但 WordPress 却没有。它也不同意IIS.net documentation
  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
  • @RobertColumbia;是的,但是:这是一个有 6 年历史的答案,而且,这是一个指向 WordPress Codex 页面的链接,当/如果 URL 更改时,该页面将被重定向。如果您查看其他答案中的链接,您会发现链接失效的可能性更大。
【解决方案3】:

为了帮助其他用户,这个问题是由 IIS 中的权限引起的,这里也有一个修复:

http://forums.iis.net/t/1159252.aspx

【讨论】:

    【解决方案4】:

    在您的 web.config 文件中使用下面提到的规则 ..

      <rule name="Imported Rule 1" stopProcessing="true">
            <match url="^index\.php$" ignoreCase="false"/>
            <action type="None"/>
        </rule>
    
        <rule name="Redirect Image to HTTP" stopProcessing="true">
            <match url=".*\.(gif|jpg|jpeg|png|css|js)$" ignoreCase="true"/>
            <action type="Rewrite" url="{R:0}"/>
        </rule>
    
        <rule name="Imported Rule 2" stopProcessing="true">
            <match url="." ignoreCase="false"/>
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
            </conditions>
            <action type="Rewrite" url="/index.php"/>
        </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 2012-04-06
      • 2020-03-16
      相关资源
      最近更新 更多