WordPress经验

单个WP多域名绑定的办法

有些人域名很多,但是只是搞了一个WP博客,所以就想给WP绑定多个域名,首页是没有问题的,关键是想连文章页面也是区分不同地址,刚好在群上看到这个一个信息,就顺手的转来给大家,需要的看下吧,我虽然这个博客目前也启用了3个域名,但下面介绍具体操作方法:

首先,需要注意的是,必须是Wordpress个人版,不能是WPMU版.而是怎么绑定到多个域名上去呢?当然你需要对php有一点了解才行.

好了,废话少说,看操作方法.

第一种方法:首先,把wordpress所有文件上传到你的空间,然后把所有的域名指向到你的空间目录.

然后,打开wp-config.php,并进行如下编辑.为了简单一点,我提供几个例子,比如你有3个域名需要绑定,free5.org,freeg.pp.ru,xya.in,那么wp-config.php就会如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// ** MySQL settings ** //
define('DB_NAME', 'dbname'); // The name of the database
define('DB_USER', 'user'); // Your MySQL username
define('DB_PASSWORD', 'password'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
// You can have multiple installations in one database if you give each a unique prefix
$current_sitename= $_SERVER[’HTTP_HOST’];
if (($current_sitename == “free5.org”) || ($current_sitename == “free5.org”)){
$table_prefix = ‘free5_’; // Only numbers, letters, and underscores please!
}elseif (($current_sitename == “freeg.pp.ru”) || ($current_sitename == “freeg.pp.ru”)){
$table_prefix = ‘freeg_’; // Only numbers, letters, and underscores please!
}elseif (($current_sitename == “xya.in”) || ($current_sitename == “xya.in”)){
$table_prefix = ‘xya_’; // Only numbers, letters, and underscores please!
}

ok!

Read more…

Be the first to comment - What do you think?  Posted by google - 2009-11-18 at 12:25

Categories: WordPress经验   Tags: