2016-09-22 142 views
0

我遇到了使用IIS URl重定向模塊的問題。 試圖從www.site.com/directory1/default.aspx 重定向到www.site.com/directory2/default.aspxIIS URL重定向目錄

所以要directory1中的任何請求需要到目錄2.我將是禁用目錄中的應用程序1 任何想法? 目前我有以下,但不起作用。

<rewrite> 
      <rules> 
       <remove name="Portal Test Redirect" /> 
       <rule name="Portal Test Redirect" patternSyntax="Wildcard"> 
        <match url="*directory1/*" ignoreCase="false" /> 
        <conditions /> 
        <serverVariables /> 
        <action type="Rewrite" url="{R:1}/directory2/{R:2}" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite>   

回答

0

1.Open web.config文件的目錄中的舊網頁駐留 2.然後添加代碼的老位置的路徑和新的目標如下:

<configuration> 
 
    <location path="services.htm"> 
 
    <system.webServer> 
 
     <httpRedirect enabled="true" destination="http://domain.com/services" httpResponseStatus="Permanent" /> 
 
    </system.webServer> 
 
    </location> 
 
    <location path="products.htm"> 
 
    <system.webServer> 
 
     <httpRedirect enabled="true" destination="http://domain.com/products" httpResponseStatus="Permanent" /> 
 
    </system.webServer> 
 
    </location> 
 
</configuration>

請嘗試以上。從Setting up redirect in web.config file

1

您需要更改您的規則,如下

<rewrite> 
    <rules>    
     <rule name="Portal Test Redirect"> 
      <match url="(.*)(directory1)(.*)" patternSyntax="ECMAScript"/> 
      <action type="Rewrite" url="{R:1}directory2{R:3}" /> 
     </rule> 
    </rules> 
</rewrite> 
+0

會這樣處理的查詢字符串參數以及Refered?我所需要的是要更改的目錄 – tichra

+0

是的,它應該是,但我沒有測試它。 –

+0

你還在遇到問題嗎? –