无法将.htaccess转换为web.config

时间:2015-06-28 14:13:30

标签: asp.net .htaccess web-config

这个代码的个人资料

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

我正在使用

<rule name="rule 1A" stopProcessing="true">
<match url="."  />
<action type="Rewrite" url="/index.php"  />
</rule>

但没有工作......为什么?

1 个答案:

答案 0 :(得分:0)

此配置解决了我的问题

<?xml version="1.0"?>

  

<rewrite>
  <rules>
    <rule name="DeduplicateSlashes" stopProcessing="true">
      <match url="." ignoreCase="false" />
      <conditions>
        <add input="{URL}" pattern="^(.*)//(.*)$" ignoreCase="false" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="{C:1}/{C:2}" />
    </rule>
    <rule name="CleanRouting" 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="?id={R:0}&amp;{QUERY_STRING}" appendQueryString="false" />
    </rule>
  </rules>
</rewrite>

<!-- Double escaping is needed for URLs with '+', e.g. for the account page for a username with a space. -->
<security>
  <requestFiltering allowDoubleEscaping="true" />
</security>

 </system.webServer>
</configuration>