我在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 Rewrite”工具来翻译格式,并且总结如下:
<?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="^""$" 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 - 内部服务器错误。您的资源存在问题 正在寻找,它无法显示。
出现此错误的原因是什么?
答案 0 :(得分:0)
请确保已在IIS上安装并启用了URL重写模块。否则,IIS无法理解web.config文件中的标记。