将subdomain.mydomain1.com屏蔽为subdomain.mydomain2.com [英] Mask subdomain.mydomain1.com to subdomain.mydomain2.com

查看:84
本文介绍了将subdomain.mydomain1.com屏蔽为subdomain.mydomain2.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有customer.mydomain1.com,并想将其屏蔽到customer.mydomain2.com

I have got customer.mydomain1.com and want to mask it to customer.mydomain2.com

以使customer.mydomain1.com显示customer.mydomain2.com的内容,并且网址与customer.mydomain1.com保持相同

so that customer.mydomain1.com shows content of customer.mydomain2.com and url stays the same as of customer.mydomain1.com

我正在使用.htaccess中使用的以下代码,这使我出现错误400

I am using the code below used in my .htaccess, which gives me ERROR 400

RewriteEngine On
RewriteCond %{HTTP_HOST} ^customer.mydomain1.com
RewriteRule ^(.*) http://customer.mydomain2.com/$1 [P]

推荐答案

我只使用ServerAlias,该方法适用于任何具有A记录或CNAME指向您的服务器的域:

I would just use a ServerAlias this works for any domain that have an A-Record or a CNAME pointing to your server:

<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_rewite与mod_proxy一起使用([P]标志所必需) 所有列出的域(您可以添加任意多个域)

No need to use mod_rewite with mod_proxy (required for the the [P] Flag) All listed domains (you can add as many you like)

  • customer.mydomain2.com
  • www.customer.mydomain2.com
  • customer.mydomain1.com
  • example.com

将使用/var/www/path/to/public_html的内容进行响应,因此只需将其替换为customer.mydomain2.com服务器的公共目录即可.

will respond with the content of /var/www/path/to/public_html so just replace it with the public directory of your customer.mydomain2.com server.

这篇关于将subdomain.mydomain1.com屏蔽为subdomain.mydomain2.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆