WWW in address bar cause problem
I have a silly question which drive me crazy. I have ASP programed website which when you use address like http://mysite.com/ it will work. If you use http://www.mysite.com/ it would not work. Basically when 开发者_开发知识库you use "www" in the beginning of the address the website will not function properly and specially login page will not work at all.
Any idea????
This question belongs elsewhere, but here's something you can do.
Change your .htaccess file on the public_html folder of your website so you get a redirect from http://www.mysite.com to http://mysite.com
RewriteEngine on
RewriteCond %{http_host} www\.mysite\.com
RewriteRule (.*) http://mysite.com/$1 [r=301,l]
If you use IIS, download the URL Rewrite Module.
Modify the web.config file to include the following:
<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>
This is referred to as a "Canonical Redirect".
In IIS Manager, make sure that the Website is set up to listen for both host headers.
IIS 6 Instructions: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/883a9544-3f70-4d46-a6df-bbadbd1fe7de.mspx?mfr=true
IIS 7 Instructions: http://technet.microsoft.com/en-us/library/cc753195(WS.10).aspx
精彩评论