如何从iis windows server urls中删除Index.php

时间:2015-04-17 10:02:25

标签: php wordpress url iis

第一次使用IIS服务器。在服务器上安装wordpress。问题是网站没有在网址中没有index.php的情况下工作。

stackoverflow尝试此操作。执行此操作后,显示错误500。我的webconfig文件是

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <defaultDocument enabled="true">
      <files>
        <clear />
        <add value="index.aspx" />
        <add value="index.asp" />
        <add value="index.htm" />
                 <add value="index.php" />
        <add value="index.html" />
        <add value="home.aspx" />
        <add value="home.asp" />
        <add value="home.htm" />
        <add value="home.html" />
        <add value="default.aspx" />
        <add value="default.asp" />
        <add value="default.htm" />
        <add value="default.html" />
      </files>
    </defaultDocument>
 <directoryBrowse enabled="true" />
  </system.webServer>
</configuration> 

也试图改变这个

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
 <defaultDocument>
     <!-- Set the default document -->
      <files>
        <remove value="index.php" />
        <add value="index.php" />
      </files>
    </defaultDocument>
        <httpErrors errorMode="Detailed"/>
    <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>

1 个答案:

答案 0 :(得分:1)

尝试在web.config上使用此功能。

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.web>
        <customErrors mode="Off" />
        <compilation debug="true" />
    </system.web>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{R:1}" pattern="\.(gif|jpe?g|png)$" negate="true" />
                        <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/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    <security>
            <requestFiltering allowDoubleEscaping="true" />
     </security>
    </system.webServer>
</configuration>