蹭网器价格

wordpress绑定多个域名

时间: 2010-03-09 / 分类: wordpress技巧 / 浏览次数: 71 次 / 1个评论 发表评论

如果你有多个域名闲置,都想用,可是 wordpress只许咱用一个域名,看了看文档和说明,发现是可以处理解决的。
wp-includes/functions.php 文件中反回两个域名的函数:_config_wp_home() , _config_wp_siteurl() 的说明文字已经很清楚了,只要是WP_HOME常量已经定义过了的话,在取网站的域名时就会优先采用WP_HOME的值,WP_SITEURL同理。

/**
* Retrieve the WordPress home page URL.
*
* If the constant named 'WP_HOME' exists, then it willl be used and returned by
* the function. This can be used to counter the redirection on your local
* development environment.
*
* @access private
* @package WordPress
* @since 2.2.0
*
* @param string $url URL for the home location
* @return string Homepage location.
*/
function _config_wp_home( $url = '' ) {
if ( defined( 'WP_HOME' ) )
return WP_HOME;
return $url;
}

因此,我们直接在 /wp-config.php 文件的

/**
* Retrieve the WordPress home page URL.
*
* If the constant named 'WP_HOME' exists, then it willl be used and returned by
* the function. This can be used to counter the redirection on your local
* development environment.
*
* @access private
* @package WordPress
* @since 2.2.0
*
* @param string $url URL for the home location
* @return string Homepage location.
*/
function _config_wp_home( $url = '' ) {
if ( defined( 'WP_HOME' ) )
return WP_HOME;
return $url;
}

代码之上(一定要在它之上,之上任何位置都可以),加上以下代码:

/** /
本人一向不喜欢不带www的域名,虽然输网址的时候一般都不输www,但带上www的域名看起来要舒服一点,呵呵,还得处理一下。
将 aaa.com 转换为 www.aaa.com 如果不需要如此转换,可直接写成: $_asdfasdf_myurl = 'http://'.$_SERVER['HTTP_HOST'];
/**/
$_asdfasdf_myurl = preg_replace( '|^(www\.)?(.*)$|', 'http://www.\2', $_SERVER['HTTP_HOST']);
define('WP_HOME', $_asdfasdf_myurl);
define('WP_SITEURL', $_asdfasdf_myurl);
unset($_asdfasdf_myurl);//清理掉这个变量,以免影响后面的程序

修改后你会发现后台“常规设置”里面的 “WordPress 安装地址 (URL)”和”博客地址 (URL)”已经变成灰色了,也就是不起作用了。还有就是,“杂项”里面的“文件的完整URL地址”需要删除掉有http://…网址的那部份,如果是空就可以不用管啦。
快试试你的其他域名吧!
其他版本的wordpress应该也是一样的方法。

来源:http://www.like.com.ru/?p=25

无觅相关文章插件

其他人还看了



本文标签: wordpress, 多域名绑定



给资源评分:
1 星2 星3 星4 星5 星 (暂无评价)
载入中…… ... 载入中…… ...
免费空间申请订阅

1个评论

  1. 摇滚
    2010/03/27 于 18:28:33

    从blogsearch搜到了这篇文章,真的很不错,希望能看到更多的新内容,已经订阅了rssfeed,祝博主好运:)

发表评论

您的昵称 *

您的邮箱 *

您的网站

蹭网卡报价_免费asp空间申请的地址_如何申请免费域名教程及攻略_免费域名空间申请的方法