c# - Best way to redirect wrong url's -


imagine scenario, have:

wellspell.com 

as well

wellspeel.com weelspell.com weelspeel.com 

and want mvc application work correct domain name.

my current problem resides on lack of support on cname under current dns control panel can add *.wellspeel.com , www.wellspeel.com never wellspeel.com (only aname).

what easiest configuration can redirect http://wellspeel.com http://wellspell.com ?

what have now in first controller, simple check using requestcontext.httpcontext.request.url.host , filtered , redirect user

requestcontext.httpcontext.response.redirectpermanent("http://wellspell.com"); 

but inside controller initialization... can redirect before reaching controller?

i looking documentation regarding urlroutingmodule after few attempts lost...

can point me right direction, or has issue , how did guys solved it?


p.s. thinking create simple handler in new website , in website bindings add "bad" domains , redirect there, using maybe simple xml configuration easier update...

if running iis 7 or later make sure of http redirect , skip having stand code.

edit: reason assuming standing iis sites each possible domain. if setting 1 iis site , including multiple bindings each possible domain, might want using iis url rewrite rules (this still let skip having configure code rules executed before mvc pipeline).

specifically, think interested in http_host condition input.

here (untested) example:

<system.webserver>     <rewrite>         <rules>             <rule name="spellingerrorone" stopprocessing="true">                 <match url="(.*)" />                 <conditions>                     <add input="{http_host}" pattern="^weelspeel.com" />                 </conditions>                 <action type="redirect" url="http://wellspell.com" />             </rule>         </rules>     </rewrite> </system.webserver> 

you need add rule each domain want handle. <condition> acts criteria has validate in order action (e.g. redirect) executed.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -