最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

multisite - $_SERVER['SERVER_NAME'] in WP_SITEURL

programmeradmin4浏览0评论

My client has two domains, and wishes to split a product catalogue over them. They want to have a shopping cart that is shared over both, i.e. a shared session over the two domains, this is solved in principle at least, and not the point of this question.

Am using WooCommerce (no choice in this).

Since the products need to available to be ordered in one transaction, they need to be in the same database, so I don't think a normal multisite install is going to work.

I'm hoping therefore to be able to use a single WP install, and simply put $_SERVER['SERVER_NAME'] in WP_SITEURL & WP_HOME.

I've seen very few references to doing this, so I'm nervous about possible unforeseen consequences.

Can anyone reassure me, or perhaps tell me why I shouldn't do this?

My client has two domains, and wishes to split a product catalogue over them. They want to have a shopping cart that is shared over both, i.e. a shared session over the two domains, this is solved in principle at least, and not the point of this question.

Am using WooCommerce (no choice in this).

Since the products need to available to be ordered in one transaction, they need to be in the same database, so I don't think a normal multisite install is going to work.

I'm hoping therefore to be able to use a single WP install, and simply put $_SERVER['SERVER_NAME'] in WP_SITEURL & WP_HOME.

I've seen very few references to doing this, so I'm nervous about possible unforeseen consequences.

Can anyone reassure me, or perhaps tell me why I shouldn't do this?

Share Improve this question asked Nov 12, 2013 at 11:26 jezmckjezmck 658 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Personally, I make them default to the HTTP host:

define('WP_HOME',     'http://' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL',  'http://' . $_SERVER['HTTP_HOST']);

There are no caveats for single WP installs. It's in fact very convenient when testing changes in a dev.example subdomain, in the sense that it allows to use the same database before rolling out a change on a live site.

Don't do this in multisite installs, however — especially you plan want domain mapping. :-)

发布评论

评论列表(0)

  1. 暂无评论