我有customer.mydomain1.com,并希望将其掩码为customer.mydomain2.com
因此,customer.mydomain1.com显示customer.mydomain2.com的内容,url保持与customer.mydomain1.com相同
我在我的.htaccess中使用了下面的代码,它给出了错误400
RewriteEngine On
RewriteCond %{HTTP_HOST} ^customer.mydomain1.com
RewriteRule ^(.*) http://customer.mydomain2.com/$1 [P]发布于 2017-09-30 21:22:04
我只会使用ServerAlias,它适用于任何有A记录或指向您的服务器的CNAME的域:
<VirtualHost *:80>
ServerName customer.mydomain2.com
ServerAlias www.customer.mydomain2.com customer.mydomain1.com example.com
DocumentRoot /var/www/path/to/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log common
</VirtualHost>不需要使用带有mod_proxy的mod_rewite (对于P标志是必需的)所有列出的域(您可以添加任意多个)
将使用/var/www/path/to/public_html的内容进行响应,因此只需将其替换为您的customer.mydomain2.com服务器的公共目录。
发布于 2017-09-29 19:42:19
我看不出你的配置有什么问题。我在本地apache上使用了此配置,因此两个域位于相同的HTTPD上:
<VirtualHost *:80>
ServerName customer.mydomain1.com
ErrorLog "logs/error_mydomain1_log"
CustomLog "logs/access_mydomain1_log" common
RewriteEngine On
RewriteCond %{HTTP_HOST} ^customer.mydomain1.com
RewriteRule ^(.*) http://customer.mydomain2.com/$1 [P]
</VirtualHost>
<VirtualHost *:80>
ServerName customer.mydomain2.com
ErrorLog "logs/error_mydomain2_log"
CustomLog "logs/access_mydomain2_log" common
DocumentRoot "/home/tools/apache/htdocs/mydomain2"
DirectoryIndex index.html
</VirtualHost>然后更改我的本地主机文件以定义这两个域,并且它可以工作。如果我访问http://customer.mydomain1.com,我会得到index.html的内容。我还在customer.mydomain2.com上的子目录中创建了其他文件,当我访问它们时,customer.mydomain1.com会停留在地址栏中。
因此,您的配置中可能存在某些内容,或者缺少某些模块。$(apachectl -t)是否返回“语法正常”?你重启你的apache了吗?
https://stackoverflow.com/questions/46469497
复制相似问题