2011-10-15 60 views
0

我有一個網站,當人們瀏覽到http://subdomain.mysite.com/它改寫成相對路徑不與IIS重寫工作

http://mysite.com/clientArea/Default.aspx?ID=1234

,然後當人們瀏覽到http://subdomain.mysite.com/AnythingElse.aspx它,然後重寫http://mysite.com/clientArea/AnythingElse.aspx

問題出現在樣式表中,出於某些原因它們解析不正確。

在我的代碼,我讓他們進入像這樣

<link rel="Stylesheet" href="css/myStyleSheet.css" type="text/css" media="screen" /> 

但是,當我嘗試訪問我的網站:http://subdomain.mysite.com/,並期待在源,他們已經改變了這種

<link rel="Stylesheet" href="clientArea/css/myStyleSheet.css" type="text/css" media="screen" /> 

哪個沒有按沒有工作,因爲它試圖從

http://subdomain.mysite.com/clientArea/css/myStyleSheet.css

它應該嘗試從

http://subdomain.mysite.com/css/myStyleSheet.css

獲得的資源我已經試過了一堆各種修正,包括與〜和這種添加在Page.RequestUrl的,但他們都加在clientArea面前。由於我們已經在clientArea文件夾中,所以這不起作用。

任何關於此事的幫助都會很大。

這裏是我的重寫規則

<rule name="Remove Subdomain" enabled="true" stopProcessing="true"> 
       <match url="^$" /> 
       <conditions> 
        <add input="{HTTP_HOST}" pattern="^(?!www)subdomain\.mysite\.com$" /> 
       </conditions> 
       <action type="Rewrite" url="clientArea/?ID=1234" appendQueryString="true" logRewrittenUrl="true" /> 
      </rule> 
      <rule name="Everything Else" enabled="true" stopProcessing="true"> 
       <match url="(.*)" /> 
       <conditions> 
        <add input="{HTTP_HOST}" pattern="^(?!www)subdomain\.mysite\.com$" /> 
       </conditions> 
       <action type="Rewrite" url="clientArea/{R:0}" /> 
      </rule> 

回答

0

嘗試使用URLRewriter.dll和Global.ascx

if (Request.Url.AbsoluteUri.EndsWith(".jpg") || Request.Url.AbsoluteUri.EndsWith(".gif") || 
      Request.Url.AbsoluteUri.EndsWith(".png") || Request.Url.AbsoluteUri.EndsWith(".ico") || 
      Request.Url.AbsoluteUri.EndsWith(".js") || Request.Url.AbsoluteUri.EndsWith(".css")) 
     { } 
     else 
     { 
      if (!Convert.ToString(arrPath[1]).Equals("admin", StringComparison.CurrentCultureIgnoreCase)) 
      { 
       if (!Convert.ToString(arrPath[1]).Equals("demo.aspx", StringComparison.CurrentCultureIgnoreCase)) 
       { 
        URLRewriter.Rewriter.Process(); 
       } 
      } 
     } 

適用下面的代碼和寫在web配置規則的休息和嘗試。