如何将.htaccess转换为web.config?

时间:2012-08-29 12:43:07

标签: php .htaccess iis web-config

我需要将此.htaccess更改为web.config。服务器是IIS,我希望我的PHP应用程序在我的服务器上运行

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(application|modules|plugins|system|themes) index.php/$1 [L]

1 个答案:

答案 0 :(得分:0)

如果您安装了IIS,请打开管理器,单击任何站点,单击URL Rewrite,在右侧面板上选择导入规则并粘贴.htaccess规则:

<rewrite>
  <rules>
    <rule name="Imported Rule 1">
       <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" />
    <add input="{R:1}" pattern="^(index.php|robots.txt)" ignoreCase="false" negate="true" />
  </conditions>
  <action type="Rewrite" url="index.php/{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
  <match url="^(application|modules|plugins|system|themes)" ignoreCase="false" />
  <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
  </conditions>
  <action type="Rewrite" url="index.php/{R:1}" />
</rule>