I'm confused, I have a miltisite wordpress installation but also another site managing the customer areas. So I have the site on the main domain www.domaine.com and i installed the wordpress multisite in a subdomain: sites.domain.com
So far everything is fine, but when I want to create a site, wordpress requires me to be subject to the subdomain like this: other.site.domain.com
I tried to modify the .htaccess and wp-config.php but when I go back to the site management it redirects me to www.domaine.com without my being able to access the wordpress multisite management...
How can I create sites with addresses under the domain and not under the subdomain like this: other.domain.com and not like this other.site.domain.com
Thanks
CodePudding user response:
You will need to make changes to both the .htaccess and wp-config.php files. First things first , you will need to modify the .htaccess file in the root directory of your website. You need to add a rewrite rule that redirects requests for subdomains to the subdirectory.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z] ).domain.com$
RewriteRule ^(.*)$ /sites/%1/$1 [L]
This will redirect requests for subdomains such as other.domain.com to the corresponding subdirectory under sites.domain.com
Next, you will need to modify the wp-config.php file in the root directory of your WordPress installation. You need to add the following code to the file:
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'domain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
This will tell WordPress to use the main domain for new sites instead of a subdomain.
CodePudding user response:
Thank you for your answer, I just tested but it does not react correctly.
When I put the configuration of DOMAIN_CURRENT_SITE
on domaine.com I can no longer access the settings of the multisite network, I am redirected to the purchase site which is on the domain.
Another thing, if I therefore create a site in a subdirectory and not in a subdomain with the SUBDOMAIN_INSTALL
configuration false, when I type test.domaine.com
a blank page appears as if there was no site or if I Type site.domain.com/test/
it works.
I cleared the caches everywhere and tried again but nothing happened.
In case I expressed myself badly,
www.domain.com
= The commercial site of the company
site.domain.com
= Multisite management and sample site
other1.domain.com
= Customer site created from site.domain.com
thanks again