How to automatically parse a subdomain with WordPress

We have a unique WordPress installation and the front page is an iframe that needs to redirect to an address which depends on the URL it’s being accessed from (more specifically, it depends on the subdomain).

Let’s say, if the address is :

Read More
<subdomain>.<Domain>

then the iframe should redirect to:

<subdomain>.<OtherDomain>

ex:
chc.mynewdomain.com
should contains an iframe redirecting to:
chc.myolddomain.com

The questions are:
1- how to have all subdomains go to that unique wordpress install?
2- how to parse the subdomain in the underlying WordPress (PHP) code, possibly check against a white list of subdomains, and build up dynamically the iframe URL?

Related posts

Leave a Reply

1 comment

  1. To have all subdomains go to the same wordpress install:

    • first, setup a wildcard domain entry. procedure varies depending on the dns host
    • then setup a wild card entry in your httpd config (typically involves adding a * in hostname)
    • As for handling it in wordpress, depends what you are trying to do. The most likely scenario is you want a different page for every subdomain so you will have to enable wordpress multi site for multiple site. Then, you will have to install the domain mapping plugin. A url that describes that is here: http://wp.tutsplus.com/tutorials/wordpress-multisite-beyond-basics-essentials-and-domain-mapping/