2013-02-13 111 views
5

我有一些需要在http中的文件。我嘗試了下面的代碼,但不起作用。 我如何設置的網頁第1頁力HTTP,第2頁在web.config中如何在web.config文件中爲某些文件強制http

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Force HTTP" stopProcessing="true"> 
       <match url="(.*)/page1.php" ignoreCase="false"/> 
           <match url="(.*)/page2.php" ignoreCase="false"/> 
       <conditions> 
        <add input="{HTTPS}" pattern="ON" ignoreCase="true"/> 
       </conditions> 
       <action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" /> 
      </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

蔭在IIS 7的Web服務器工作在Windows PHP應用程序

回答

3

您需要您的規則更改爲:

<rule name="Force HTTP" stopProcessing="true"> 
    <match url="^page[12].php(.*)" /> 
    <conditions> 
    <add input="{HTTPS}" pattern="^ON$" /> 
    </conditions> 
    <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" /> 
</rule> 

url="^page[12].php(.*)"將匹配開始page1.phppage2.php任何URL。
該操作將請求重定向到https://{HTTP_HOST}/{R:0},其中{R:0}包含請求的路徑。

+0

謝謝... :)。 我的意思是像不同的頁面(onpage,anoher page)。我將匹配標記更改爲。此外,重定向是http而不是https。現在它工作正常。再次非常感謝你。 – suneesh 2013-02-14 05:28:25

+0

@suneesh對,重定向到'HTTPS'是一個錯字!對不起:) – cheesemacfly 2013-02-14 15:08:29

相關問題