2012-09-23 95 views
1

我有一个PHP CMS在Apache和我的.htaccess低于此:如何将.htaccess代码转换为web.config?

# -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] 

,我想翻译它的Web.config的IIS Web服务器。

我搜索,我发现“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 - 内部服务器错误。您正在查找的资源存在问题,并且无法显示。

可能是这个错误的原因是什么?

回答

0

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