How to provide a temporary URL for custom domain in Wordpress multisite install?

Posted by Milan Babuškov on Stack Overflow See other posts from Stack Overflow or by Milan Babuškov
Published on 2011-01-15T20:15:38Z Indexed on 2011/01/16 12:53 UTC
Read the original article Hit count: 189

Filed under:
|
|

I have a website with Wordpress 3.0.4 installation, set up as multisite install. Some users register their blogs as something.mydomain.com and that works automatically. However, some users prefer to use their own domain names like something.com. This also works fine once they set up the CNAME record to point to my server. However, it takes 24-48 hours for that change to take effect. I'd like to be able to offer the user a temporary URL that would work out-of-the-box until the DNS changes are propagated, but I have not idea how to do it?

For example:

something.com

should also be accessible as:

something.tempdomain.com

I have control over "tempdomain" DNS setup. I thought about replacing $_SERVER variables in index.php or .htaccess file when temporary domain is accessed, and this works for the first page load. However, all the links in generated page point to original domain which is not yet ready.

UPDATE: I managed to get it working for the site itself by manipulating $_SERVER variables so Wordpress thinks it's creating a page for different site. I did this in index.php, so before any WP code is run I'm using ob_start and ob_get_contents later to get the page generated by Wordpress and then str_replace the links back to temporary domain.

The problem I still have is the admin page. Even though the link says:

http://site1.tempdomain.com/wp-admin 

when opened in browser it redirects to maindomain.com/wp-signup.php?new=site1.tempdomain

I don't understand how WP detects that I supplied "fake" domain when $_SERVER vars are changed?

© Stack Overflow or respective owner

Related posts about php

Related posts about apache