URL Rewriting - Multi-Domain - Remove Folder In Path on Primary Domain -
this challenge related url rewriting in using both primary domain fictitious folder , many secondary domains (without fictitious folder) needed. idea site have default domain can use, allow users use own domain. both need extensions removed @ end. i’ll outline how should work. have working except 1 thing , i’m hoping can assist or shed light. vs 2012 application uses iis.
primary domain urls
www.primarydomain.com/anyfictitiousname/page1 www.primarydomain.com/anyfictitiousname2/page2 www.primarydomain.com/anyfictitiousname3/somepath/page3
rewritten primary domain urls
www.primarydomain.com/page1.aspx (or better yet www.primarydomain.com/page1.aspx?i=anyfictitiousname) www.primarydomain.com/page2.aspx (or better yet www.primarydomain.com/page2.aspx?i=anyfictitiousname2) www.primarydomain.com/somepath/page3.aspx (or better yet www.primarydomain.com/somepath/page3.aspx?i=anyfictitiousname3)
secondary domain urls
www.secondarydomain1.com/page1 www.secondarydomain2.com/page2 www.secondarydomain3.com/somepath/page3
rewritten secondary domain urls
www.secondarydomain1.com/page1.aspx www.secondarydomain2.com/page2.aspx www.secondarydomain3.com/somepath/page3.aspx
all of above work current rewriting code (which i’ve listed below), except when using primary domain , not including file @ end of url, falls apart. essentially, if assign url “www.primarydomain.com/personname” user, want able go address load default page rather having type “www. primarydomain.com/personname/default” if makes sense. ends happening following:
www.primarydomain.com/personname => www.primarydomain.com/personname.aspx www.primarydomain.com/personname/ => www.primarydomain.com/personname/.aspx
what want happen in case following:
www.primarydomain.com/personname => www.primarydomain.com/default.aspx (or better yet www.primarydomain.com/default.aspx?i=personname) www.primarydomain.com/personname/ => www.primarydomain.com/default.aspx (or better yet www.primarydomain.com/default.aspx?i=personname)
i’m new url rewriting, i’m not sure of correct approach, after first rule performed or part of first rule, if {r:2} nothing or “/”, i’d rewrite “default.aspx”. if redirect performed in “default.aspx” added url, okay too, don’t want have make end-user type file path @ end when entering url browser. here current rewriting code. appreciated!
<rewrite> <rules> <rules> <rule name="handle primary urls" stopprocessing="true"> <match url="^([_0-9a-z-]+)/(.*)" ignorecase="false" /> <conditions logicalgrouping="matchall"> <add input="{http_host}" pattern="^(mydomain.com|www.mydomain.com)$" /> <add input="{request_filename}" matchtype="isfile" ignorecase="false" negate="true" /> <add input="{request_filename}" matchtype="isdirectory" ignorecase="false" negate="true" /> </conditions> <action type="rewrite" url="{r:2}.aspx?q={r:1}" appendquerystring="true" /> </rule> <rule name="remove aspx"> <match url="(.*)" /> <conditions logicalgrouping="matchall"> <add input="{request_filename}" matchtype="isfile" negate="true" /> <add input="{request_filename}" matchtype="isdirectory" negate="true" /> </conditions> <action type="rewrite" url="{r:1}.aspx" /> </rule> </rules> </rules> </rewrite>
Comments
Post a Comment