我有一个网站,是建立和运行,并已经得到了另一个域和需求的重定向任何访问到 exampleA.com
或分域的话,一个页面,其中的我可以检查的要求页的子域名网站的动态列表,如果它匹配的它 exampleB.com ,如果不是对 exampleB.com 。不会有任何网站都在
exampleA.com
是主域名只是一个较短的版本。主要的网站是一个字preSS网站。
I have a site that is up and running and have gotten another domain and need redirect any visit to exampleA.com
or any sub-domain of it, to a page where I can check the requested page's sub-domain to a dynamic list of sites and if its a match send it to that sub-domain on exampleB.com
, and if not send it to the main site on exampleB.com
. there will be no site at all on exampleA.com
is is just a shorter version of the main domain. The main site is a wordpress site.
我有什么。
我有 exampleA.com
和 exampleB.com
与 exampleB.com
有子域。
我需要什么。
重定向 *。exampleA.com
到 exampleB.com/somePage/?from = *
在它到达 exampleB.com/somePage/?from = *
我可以检查 $ _ GET
信息。但我不知道如何将任意子域设置为 $ _ GET
After it gets to exampleB.com/somePage/?from=*
I can check the $_GET
info. but I'm not sure how to set the arbitrary sub-domain to the $_GET
您会需要几件事情:
一)exampleA.com的DNS设置必须被配置为允许通配符子域:
a) exampleA.com's DNS setup must be configured to allow wildcard subdomains:
*.exampleA.com. 3600 IN A x.x.x.x
二)exampleA.com的Web服务器配置必须允许通配符主机匹配
b) exampleA.com's web server configuration must allow wildcard host matching
<VirtualHost ...>
ServerName exampleA.com
ServerAlias *.exampleA.com
</VirtualHost
C)exampleA.com的默认文档将提取的主机名使用并发出重定向例B与提取的主机名。一个简单的PHP脚本
c) exampleA.com's default document would be a simple PHP script that extracts the hostname in use and issues a redirect to exampleB with the extracted host name.
<?php
$requested_host = $_SERVER['HTTP_HOST'];
$parts = explode('.', $requested_host);
array_pop($parts); // com
array_pop($parts); // exampleA
$requested_subhost = implode('.', $parts);
header("Location: http://exampleB.com/?from=$requested_subhost");
上一篇:具体的子域名指向一个路径和动态的子域名指向到其他路径路径、域名、具体、动态
下一篇:允许的URL没有与URL重写任何扩展,如exemple.com/forum重写、URL、exemple、forum