I want to resolve two domain names to the same IP address of 209.221.156.243. However, after configuring apache, the two domain names always point to the same site.
The configuration code is as follows:
NameVirtualHost 209.221.156.243: 80
ServerName xx.com
DocumentRoot d:/aa
ErrorDocument 404/404 .html
ErrorLog "| bin/rotatelogs.exe-l d:/aa/logs/errorlog. % Y-% m-% d-% H _ % M _ % S. log 86400"
CustomLog "| bin/rotatelogs.exe-l d:/aa/logs/access % Y-% m-% d. log 86400" combined
RewriteEngine on
RewriteCond % {HTTP_HOST} ^ xx.com [NC]
RewriteRule ^ (. *) $ http://www.xx.com $1 [L, R = 301]
RewriteEngine On
RewriteCond % {REQUEST_METHOD} ^ TRACE
RewriteRule. *-[F]
ServerName yy.com
DocumentRoot d:/bb
ErrorDocument 404/404 .html
ErrorLog "| bin/rotatelogs.exe-l d:/bb/logs/errorlog. % Y-% m-% d-% H _ % M _ % S. log 86400"
CustomLog "| bin/rotatelogs.exe-l d:/bb/logs/access % Y-% m-% d. log 86400" combined
RewriteEngine on
RewriteCond % {HTTP_HOST} ^ yy.com [NC]
RewriteRule ^ (. *) $ http://www.yy.com $1 [L, R = 301]
RewriteEngine On
RewriteCond % {REQUEST_METHOD} ^ TRACE
RewriteRule. *-[F]
Access yy.com but access xx.com! I have found a lot on the Internet, but I have not found the correct solution. hope experts can help me.
Reply to discussion (solution)
How can I identify the same port?
How can I identify the same port?
If the domain name is a different port, it must be followed by a port number to access it!
I have not found any writing problems.
It may be related to the apache version or other settings.
I have not found any writing problems.
It may be related to the apache version or other settings.
The strange thing is that after I configure the second one to www.yy.com
When I access www.yy.com, I can access the program under bb correctly.
However, yy.com without www still accesses the program under aa, that is, www.xx.com!
Reference the reply from xuzuning on the third floor: I did not find any problem in writing the code.
It may be related to the apache version or other settings.
The strange thing is that after I configure the second one to www.yy.com
When I access www.yy.com, I can access the program under bb correctly.
However, yy.com without www still accesses the program under aa, that is, www.xx.com!
After configuring the second ServerName to www.yy.com
According to the rule, yy.com is a domain, and www.yy.com is a domain name.
It may be related.
You can try to comment out the global Section 1
Er, single point of access
ServerName must be a domain name
The reason may be that your RewriteRule is for www.
Thank you two for solving the problem. It is indeed related to domain name rules and 301 redirection rules. Close the post.