2013-10-09 39 views
0

我在做php编程IIS。我使用的php框架是Yii。隐藏index.php并使用友好的URL我启用urlManagerconfig.php文件。我的问题是,当我尝试导航到我的控制器服务器返回错误404。我认为重写规则有问题,但我不熟悉IIS Web服务器。有谁能够帮助我?重写规则在IIS上不起作用

+1

请阅读答案IIS文档。 –

+0

@Matt你会给我链接吗? – hamedkh

+1

这很容易找到一个简单的谷歌搜索。请付出一些努力。 –

回答

2

我已经解决了我的问题。这是原来的规则.htaccess

RewriteEngine on 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

这里是它的翻译web.config格式:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 

<directoryBrowse enabled="false" /> 

    <rewrite> 
     <rules> 
     <rule name="Hide Yii Index" 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" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 

</system.webServer> 
</configuration>