2011-10-07 76 views
3

如何将.htaccess转换为web.config。htaccess不能在iis上工作

我刚才知道我需要使用web.config而不是htaccess。请在下面找到我的htaccess

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

如何将其转换为web.config?

回答

4

复制粘贴下面的代码在你的web.config

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="Imported Rule 1" 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/{R:1}" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 
+0

漂亮的代码...请指导我如何变成web.config中RewriteEngine叙述这在 有FollowSymLinks RewriteBase/ 的RewriteCond%{REQUEST_FILENAME }!-f 的RewriteCond%{REQUEST_FILENAME}!-d 重写规则^(。*)$ /#/ $ 1 [L] 的RewriteCond%{REQUEST_FILENAME}!-f 的RewriteCond%{REQUEST_FILENAME}!-d RewriteRu le ^(。*)/(。*)$ /#/ $ 1/$ 2 [L] –