2011-05-15 80 views
0

我正在使用web.config中的url重寫功能來重定向我的子域。這是我的原則:通配符重定向url重寫web.config

<rule name="redirect_page"> 
     <match url=".*" ignoreCase="false" negate="false" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^www\." negate="true" /> 
     <add input="{HTTP_HOST}" pattern="^([\w\-]+)\.mySite\.com$" /> 
     </conditions> 
     <action type="Rewrite" url="profile.aspx?name={C:1}" /> 
    </rule> 

這個偉大的工程: http://myUser.mySite.com重定向到http://myUser.mySite.com/profile.aspx?name=myUser

http://myUser.mySite.com/image/myImage.jpg重定向到http://myUser.mySite.com/profile.aspx?name=myUser

=>我想什麼: http://myUser.mySite.com/image/myImage.jpg重定向到http://myUser.mySite.com/image/myImage.jpg

任何想法?

回答

1

嗯,這是一個有點棘手,但這裏是解決方案:

<rule name="SubDomainDoNothing" stopProcessing="true"> 
     <match url="(.+)" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.plugandtable\.com$" /> 
     </conditions> 
     <action type="Rewrite" url="{R:1}" /> 
    </rule> 

    <rule name="SubDomainRedirect" stopProcessing="true"> 
     <match url="(.*)" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.plugandtable\.com$" /> 
     </conditions> 
     <action type="Rewrite" url="profile.aspx?name={C:1}" /> 
    </rule>