将 http://mydomain.com/ctrlr/act/val 转发到 http://WWW.mydomain.com/ctrlr/act/val [英] Forwarding http://mydomain.com/ctrlr/act/val to http://WWW.mydomain.com/ctrlr/act/val
问题描述
我有一个用 ASP.NET MVC (V 1.0) 编写的应用程序.该应用程序在 IIS7 上运行,DNS 由 GoDaddy 提供.
I have an application written on ASP.NET MVC (V 1.0). The application runs on IIS7 and the DNS is provided by GoDaddy.
我想转发来自 http://mydomain.com/ctrlr/act 的任何请求/value 到这种形式的 URL:http://WWW.mydomain.com/ctrlr/act/value
I would like to forward any request that comes from http://mydomain.com/ctrlr/act/value to a URL of this form: http://WWW.mydomain.com/ctrlr/act/value
基本上,如果有人试图访问 http://mydomain.com
Basically, I want to add WWW to the Host-name if someone tries to reach http://mydomain.com
最好的方法是什么?
推荐答案
我想你会从这个问题
我同意你强制使用 www 的想法,好像 SO 决定 使用它我相信他们在调整 cookie 的性能并且不得不使用 sstatic.net 而不是 images.stackoverflow.com 说时后悔了.
I would agree with your idea of forcing the use off www, as though SO decided to use it I do believe they regretted when tweaking performance for cookies and having to use sstatic.net instead of images.stackoverflow.com say.
在这里为您节省重定向是您需要做的要点.
To save you a redirect here is gist of what you need to do.
这是将 WWW 前缀添加到所有传入 URL 的 IIS7 规则.将此 XML 片段剪切并粘贴到您的 web.config 文件中
Here’s the IIS7 rule to add the WWW prefix to all incoming URLs. Cut and paste this XML fragment into your web.config file under
<system.webServer> / <rewrite> / <rules>
<rule name="Add WWW prefix" >
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.com" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:1}"
redirectType="Permanent" />
</rule>
这篇关于将 http://mydomain.com/ctrlr/act/val 转发到 http://WWW.mydomain.com/ctrlr/act/val的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!