It seems to be a 'feature' of WordPress that it's designed to run on one, and only one host name.
The 'siteurl' and 'home' parameters are hardwired into the database options table, so if you hit the site on non-matching hostname you get redirected by PHP to the correct hostname. Even more irritatingly, the siteurl is prefixed to all internal links that are output to HTML. (alth开发者_开发知识库ough, perhaps that's the theme's fault - I haven't looked at that yet)
Is there a proper way to run WordPress on multiple domains without hacking the core, and without maintaining multiple options tables?
There's an old plugin called Domain Mirror which seems to do what you want. Not sure if it works at all with WordPress 3+, but at the very least the same principles should be sound enough that you can look in the source code and adapt it for your functions.php.
I think the proper way is to enable multi-site operation, which is a feature of WP3.0.
You do not need to maintain multiple options table. If nothing works try the following hack. The Host:
parameter can be used as a simple and quick hack. Here is how:
- Host all domains on one webserver.
- Make root dir of all same for all.
- hack the WP code and setting to modify site-url property and dynamically return
$_REQUEST['Host']/wp-directory-path/
.
Here is the request headers. The first line say it's a GET request for the /pub/WWW path and second line instructs for which domains it is. Host field is mandatory since HTTP/1.1
GET /pub/WWW/ HTTP/1.1
Host: www.w3.org
精彩评论