我有一个愚蠢的问题快把我逼疯了。我有ASP编程的网站,当你使用像http://mysite.com/这样的地址,它会工作。如果你使用http://www.mysite.com/,它将无法工作。基本上,当您在地址开头使用"www“时,网站将无法正常运行,特别是登录页面将完全不起作用。
有什么想法吗?
发布于 2011-01-25 07:12:34
这个问题应该放在别处,但这里有一些你可以做的事情。
更改网站public_html文件夹中的.htaccess文件,以便从http://www.mysite.com重定向到http://mysite.com
RewriteEngine on
RewriteCond %{http_host} www\.mysite\.com
RewriteRule (.*) http://mysite.com/$1 [r=301,l]如果您使用IIS,请下载URL Rewrite Module。
修改web.config文件以包含以下内容:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect from WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.mysite.com$" />
</conditions>
<action type="Redirect" url="http://mysite.com/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>这被称为“规范重定向”。
发布于 2011-01-26 03:53:59
https://stackoverflow.com/questions/4788235
复制相似问题