2014-10-20 82 views
0

我在.htaccess文件中有這些行,並將我的網站移至IIS環境。我很確定它需要進入根目錄下的web.config文件,但我完全失去了,並沒有運氣嘗試一切。它所做的就是將任何帶有.php,.htm或.html的東西引導到根目錄中的index.php頁面,這樣我就可以控制顯示的內容,並使事物模塊化。它會在查詢字符串中查找文件名,以便我可以直接從那裏獲取內容。反正繼承人什麼我對的.htaccess:將.htaccess(PHP)行轉換爲web.config行(IIS)

RewriteCond %{REQUEST_FILENAME} (\.php|.htm|.html)$ 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 

回答

1

可以導入並使用此Microsoft支持URL Rewrite IIS Manager module

web.config

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Rule 1" stopProcessing="true"> 
        <match url="^(.*)$" ignoreCase="false" /> 
        <conditions logicalGrouping="MatchAll"> 
         <add input="{REQUEST_FILENAME}" pattern="\.(php|htm|html)$" ignoreCase="false" /> 
        </conditions> 
        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 
0
轉換 mod_rewrite rulesIIS URL rewrite rules

我非常感謝你指着我回來在url重寫模塊的方向。我已經嘗試使用,但並不知道它有導入功能!在我導入了.htaccess文件後,它仍然無法正常工作(正如我們所期望的那樣,導入大聲笑),但是在我調整好reqex後,所有的工作都正常了!再次感謝你幫助我。對於任何需要爲此設置正確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 logicalGrouping="MatchAll"> 
         <add input="{REQUEST_FILENAME}" matchType="Pattern" pattern="(.*php|.*htm|.*html)$" ignoreCase="true" negate="false" /> 
        </conditions> 
        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration>