1

我在 Apache 中有一个 PHP CMS,我.htaccess在下面:

 # -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

# AuthType Basic
# AuthUserFile /home/tcdgroup/.htpasswd
# AuthName tadbir-group

# Require user test 


RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

我想将它转换为 IIS Web 服务器的 web.config。

我搜索并找到了“URL重写”工具来翻译格式,总结如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1">
                    <match url="^\.htaccess$" ignoreCase="false" />
                    <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^.*$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="^&quot;&quot;$" ignoreCase="false" />
                    </conditions>
                    <action type="Rewrite" url="/public/index.php" />
                </rule>
                <rule name="Imported Rule 3">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="^/public/.*$" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/public/{R:1}" />
                </rule>
                <rule name="Imported Rule 4" stopProcessing="true">
                    <match url="^.*$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="Imported Rule 5" stopProcessing="true">
                    <match url="^public/.*$" />
                    <action type="Rewrite" url="/public/index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

但是当我将它上传到我的服务器时,会出现以下错误:

500 - 内部服务器错误。您要查找的资源有问题,无法显示。

此错误的原因可能是什么?

4

1 回答 1

0

请确保在您的 IIS 上安装并启用 URL 重写模块。否则,IIS 无法理解 web.config 文件中的标记。

于 2014-11-21T15:45:14.013 回答