简体   繁体   English

WordPress子域和多个站点

[英]Wordpress subdomain and multiple sites

I have a wordpress website say www. 我有一个wordpress网站说www。 flowers.com . flowers.com。 Now can i have 3 subdomain called "Roses" , "sunflower" , "orchids" with a fresh wp install eg: www. 现在,我可以使用一个名为ws的wp新安装的3个子域,分别称为“玫瑰”,“向日葵”,“兰花”。 roses.flower.com , and main website got links pointing each sub dir index file. rose.flower.com和主要网站上都有指向每个子目录索引文件的链接。 And they all working fine 他们都工作正常

Now how do one user log in all sites with one user name ? 现在,一个用户如何使用一个用户名登录所有站点?

I tried using same sql directory database on all subdomain sites, but still each and every time the user need to login for different subdomains . 我尝试在所有子域站点上使用相同的sql目录数据库,但是每次用户每次都需要登录不同的子域时,仍然尝试使用相同的sql目录数据库。

all ideas are welcome . 欢迎所有想法。

thanks in advance :) 提前致谢 :)

You can use the wordpress "multisite" feature and then link each individual blog to a subdomain. 您可以使用wordpress的“多站点”功能,然后将每个博客链接到一个子域。

More about multisite: http://codex.wordpress.org/Create_A_Network 有关多站点的更多信息: http : //codex.wordpress.org/Create_A_Network

Hope that helps 希望能有所帮助

Solution : 解决方案:

Our goal is to set up two WordPress websites which will share logins and the same users. 我们的目标是建立两个可以共享登录名和相同用户的WordPress网站。 Once a user has subscribed one website, she would be able to access the other website with the same role and capabilities. 用户订阅了一个网站后,便可以使用相同的角色和功能访问另一个网站。

Step 1: In order to share the same users and usermeta tables, WordPress installations must share the same database. 步骤1:为了共享相同的用户和usermeta表,WordPress安装必须共享相同的数据库。

Add prefix of first wordpress installation first_ and second wordpress installation table second_. 添加第一个wordpress安装first_和第二个wordpress安装表second_的前缀。 in same database. 在同一个数据库中。

Step 2: When the first WordPress website is up and running, we can edit its configuration file. 步骤2:当第一个WordPress网站启动并运行时,我们可以编辑其配置文件。 Open /first/wp-config.php and add the following lines above the 'stop editing' comment: 打开/first/wp-config.php并在“停止编辑”注释上方添加以下行:

 $table_prefix  = 'first_';
    define('WP_DEBUG', true);
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    @ini_set( 'display_errors', 0 );

// custom users and usermeta tables
define( 'CUSTOM_USER_TABLE', $table_prefix . 'users' );
define( 'CUSTOM_USER_META_TABLE', $table_prefix . 'usermeta' );

/* That's all, stop editing! Happy blogging. */

Step 3: We are done with the first installation. 步骤3:我们完成了第一次安装。 Next we have to copy wp-config.php from the first installation folder and paste it into the root folder of the second installation. 接下来,我们必须从第一个安装文件夹复制wp-config.php并将其粘贴到第二个安装的根文件夹中。 Be careful to change the $table_prefix value accordingly: 请注意相应地更改$ table_prefix值:

open /second/wp-config.php.and add the following lines above the 'stop editing' comment: 打开/second/wp-config.php。并在“停止编辑”注释上方添加以下行:

$table_prefix  = 'second_';

define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// custom users and usermeta tables
define( 'CUSTOM_USER_TABLE', 'first_users' );
define( 'CUSTOM_USER_META_TABLE', 'first_usermeta' );

Step 4: write in both wp-config.php for sharing cookies. 步骤4:在两个wp-config.php中编写共享Cookie。

//Share cookies
define('COOKIE_DOMAIN', '.xyz.com');
define('COOKIEHASH', 'aee53c017c29dc0d3ae37253fc8cbfd8');

Step 5: Open table "first_usermeta" and copy from column meta_key - first_capabilities and first_user_level to the second_capabilities and second_user_level. 步骤5:打开表“ first_usermeta”,并将其从meta_key-first_capabilities和first_user_level列复制到second_capabilities和second_user_level。 在此处输入图片说明

Step 6: When running the second installation, we should set a non-existent email address for admin user as WordPress finds a number of existing users from first_users table. 第6步:运行第二次安装时,我们应为admin用户设置一个不存在的电子邮件地址,因为WordPress从first_users表中找到了许多现有用户。

For more detail : https://kinsta.com/blog/share-logins-wordpress/ . 有关更多详细信息: https : //kinsta.com/blog/share-logins-wordpress/ It's Work For Me. 为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM