After setting up a website in the IIS environment, many friends habitually bind domain names with or without WWW to a website. In this way, although both domain names can be accessed, however, the weight is easily dispersed, resulting in reduced website weight.
In fact, we can automatically jump to a domain name with WWW without access. For example, when we access taotaozaixian.com, the browser automatically jumps to www.taotaozaixian.com. the browser address also displays www.taotaozaixian.com.
To sum up the methods on the internet, two methods are commonly used:
The first is to set website 301 redirection. The advantage is that the configuration is fast and simple; the disadvantage is that you need to create two sites, one real site and one empty site.
The second is to install the URL rewriting tool. The advantage is that you only need to build a real site. The disadvantage is that the configuration is slightly complicated.
The first method can refer to this article https://www.uust.com/wiki/web/86.html
The following uses the actual example to describe the second method.
1. First, resolve taotaozaixian.com www.taotaozaixian.com to the IP address of the same web server.
2. download and install the Web Platform Installer
Https://www.microsoft.com/web/downloads/platform.aspx
3. After the download and installation are complete, find and open Microsoft Web platform installer in the Start Menu.
Enter a URL in the upper-right corner of the Web Platform installer to search
Select "URL rewriting tool 2.0", click Add, and then click Install in the lower right corner
After installing IIS, You can see "URL rewriting ".
4. Configure redirection
Open a website https://www.ssffx.com/htaccess? Jdfwkey = 5 rfiq
Select "www Domain Name Redirection" on the left, and enter the complete domain name www.taotaozaixian.com with WWW in the input box on the right.
Copy the code generated below
<Files ~ "^. (Htaccess | htpasswd) $">
Deny from all
</Files>
Rewriteengine on
Rewritecond % {http_host} ^ (taotaozaixian \. com) (: 80 )? [Nc]
Rewriterule ^ (. *) http://www.taotaozaixian.com/#1 [R = 301, l]
Order deny, allow
5. Return to the IIS Site, click "URL rewriting", and click "import rules" on the right"
Paste the rewrite code into the rule and click Apply.
6. Restart the IIS Site. Enter taotaozaixian.com without WWW in the browser, and the browser will automatically jump to www.taotaozaixian.com.
The iis7 settings will redirect the domain name without www to the with WWW