Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of opening multi-user / multi-site / multi-domain name mode in wordpress

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of wordpress to open multi-user / multi-site / multi-domain name mode, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

1. Open a multi-user network

Add the following in the wp-config.php under the root of the website:

Define ('WP_ALLOW_MULTISITE', true)

Refresh the background of the website, access tools > configure the network, select "subdomain name" or "subdirectory" mode according to your needs, set up the website information, and then click "install". Only when the newly installed WordPress is bound to the domain name, you can choose the "subdomain name" mode. If you select Yes "subdomain name", after installation, please add the following code to wp-config.php in the root directory of the website:

Define ('MULTISITE', true); define (' SUBDOMAIN_INSTALL', true); define ('DOMAIN_CURRENT_SITE',' your domain name'); define ('PATH_CURRENT_SITE',' /'); define ('SITE_ID_CURRENT_SITE', 1); define (' BLOG_ID_CURRENT_SITE', 1)

If you select subdirectory, add:

Define ('MULTISITE', true); define (' SUBDOMAIN_INSTALL', false); define ('DOMAIN_CURRENT_SITE',' your domain name'); define ('PATH_CURRENT_SITE',' /'); define ('SITE_ID_CURRENT_SITE', 1); define (' BLOG_ID_CURRENT_SITE', 1)

two。 Add pseudo-static rules

If your server is using an Aache environment, replace all the code in .htaccess in the root directory of the site with the following code.

Rule code in sub-domain name mode:

RewriteEngine OnRewriteBase / RewriteRule ^ index.php$-[L] # add a trailing slash to / wp-adminRewriteRule ^ wp-admin$ wp-admin/ RewriteCond% {REQUEST_FILENAME}-f [OR] RewriteCond% {REQUEST_FILENAME}-dRewriteRule ^-[L] RewriteRule ^ (wp- (content | admin | includes). *) $1 [L] RewriteRule ^ (. * .php) $1 [L] RewriteRule. Index.php [L]

Rule code in subdirectory mode:

RewriteEngine OnRewriteBase / RewriteRule ^ index.php$-[L] # add a trailing slash to / wp-adminRewriteRule ^ ([_ 0-9a Meliza Amurz ZZ -] + /)? wp-admin$ $1wp-admin/ [Rene301 L] RewriteCond% {REQUEST_FILENAME}-f [OR] RewriteCond% {REQUEST_FILENAME}-dRewriteRule ^-[L] RewriteRule ^ (wp- (content | admin | includes). *) $2 [L] RewriteRule ^ ([. * .php) $2 [L] RewriteRule. Index.php [L]

If it is a Nginx environment, add the following rules before the last} in the server area of the domain name profile. The subdomain name and subdirectory modes are common:

Rewrite ^ / ([_ 0-9aluzAlyz -] + /)? wp-admin$ / $1wp-admin/ permanent;if (- f $request_filename) {set $rule_2 1;} if (- d $request_filename) {set $rule_2 1;} if ($rule_2 = "1") {# ignored: "-" thing used or unknown variable in regex/rew} rewrite ^ / ([_ 0-9aluzAlyz -]] + /)? (wp- (content | admin | includes). *) / $2 last Rewrite ^ / ([_ 0-9aMZ -] + /)? (.* .php) $/ $2 last;rewrite /. / index.php last

Remember to restart Nginx.

3. Set up COOKIE

This step is important. If it is not set, the login site background will prompt "error: Cookies is blocked or your browser does not support it. To use WordPress, you must enable Cookies." In wp-config.php under the root of the website, add:

Define ('COOKIE_DOMAIN',')

4. Multi-domain name mode

Click edit on the subdomain name you just added, change the "site address (URL)" inside to the specified independent domain name, and save it. If you are using the nginx environment, add other independent domain names to be used in the server_name section of the domain name configuration file and restart nginx.

If you want to automatically match multiple domain names, you can change the server_name section of the domain name profile to:

Server_name ~ ^ (www\.)? (. +) $

In this way, the Nginx multi-domain name wildcard can be realized. Any user only needs to set up his own domain name and point the resolution to the server, without the need for the administrator to add the domain name manually.

5. Troubleshooting

(1)。 If the installation theme or plug-in appears: "installation failed: unable to copy files." You can try to modify directory permissions or user groups.

Modify directory permissions, taking LNMP as an example:

Chmod 777 / home/wwwroot/ website directory-R

Modify the user group:

Chown-R www:www / home/wwwroot/ website directory /

Or reference: to perform the requested operation, WordPress requires access to your web server

(2)。 If there is no theme in the background, or only one theme is displayed, please refer to:

LNMP enables the scandir function to solve the problem that wordpress cannot scan the topic directory

Under LNMP, WordPress background theme management only shows one theme solution.

Resolve the option of not displaying the page template when WordPress creates a new page

Of course, these problems are not directly related to the multi-user mode enabled by wordpress. The system environments of different server vendors are different, and the PHP version and default configuration are different. If there are problems, please use the search.

These are all the contents of this article entitled "wordpress's way to turn on multi-user / multi-site / multi-domain name mode". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report