Je voudrais rediriger tout le trafic www au trafic non wwwasp.net mvc: Comment rediriger un non www www et vice versa
j'ai copié ceci dans mon web.config
<system.webServer>/<rewrite>/<rules>
<rule name="Remove WWW prefix" >
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain\.com" />
</conditions>
<action type="Redirect" url="http://domain.com/{R:1}"
redirectType="Permanent" />
</rule>
par ce poste
How to redirect with "www" URL's to without "www" URL's or vice-versa?
mais je suis une erreur interne du serveur 500.
cette approche fonctionne-t-elle dans MVC? Votre façon de procéder est la suivante dans Web Forms, mais je pense que le MVC Routing Framework est traité différemment. –
J'ai pris une approche très similaire. Voir http://stackoverflow.com/questions/2175975/asp-net-mvc-301-redirect-from-www-domain-com-to-domain-com – spender
@rockinthesixstring: Cela fonctionne dans MVC. Il démarre très tôt, peu importe si MVC ou WebForms va traiter la demande par la suite. –