Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two WordPress Multisite installation in different subdirectories

I have a WordPress Multisite installation here: mydomain.com I use it to have different languages like:

 mydomain.com/fr
 mydomain.com/de
 ...

Now we are changing design, but we would like to do step by step, language by language.

So we have installed another Wordpress Multisite in the folder /new, that it's working perfectly with sites like

 mydomain.com/new/fr
 mydomain.com/new/de
 ...

We would like to redirect JUST THE FRENCH language to the new wordpress. I've tried with this .htaccess in the root folder (based on the information in Wordpress documentation:

RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteCond %{REQUEST_URI} !^/fr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^fr(.*)$ /new/fr/$1
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^fr(/)?$ /new/fr/index.php [L] 

But that is giving a "Error establishing a database connection". It's weird because, as I explained, the site mydomain.com/new/fr is working perfectly.

NOTE: we don't want to use subdomains, I know that would make a different approach and solution ;-)

EDIT: The error is because this query

SELECT  blog_id FROM wp_blogs  WHERE domain IN ( 'mydomain.com' ) AND path IN ( '/fr/', '/' )  ORDER BY CHAR_LENGTH(path) DESC LIMIT 1

I guess, the redirection is working well, but when the wordpress inside "new" directory tries to determine which blog to visit, it reads the URL and it's in "/" really, since the redirection rule has an [L] and keeps the original URL in the apache environment variables.

like image 929
FlamingMoe Avatar asked Oct 17 '22 06:10

FlamingMoe


1 Answers

If you activated Multisite on WordPress 3.5 or later, you can follow the documentation setup in the section .htaccess and Mod Rewrite

According to the documentation:

.htaccess and Mod Rewrite Unlike Single Site WordPress, which can work with "ugly" Permalinks and thus does not need Mod Rewrite, MultiSite requires its use to format URLs for your subsites. This necessitates the use of an .htaccess file, the format of which will be slightly different if you're using SubFolders or SubDomains. The examples below are the standard .htaccess entries for WordPress SubFolders and SubDomains, when WordPress is installed in the root folder of your website. If you have WordPress in its own folder, you will need to change the value for RewriteBase appropriately.

like image 171
benji127 Avatar answered Oct 20 '22 23:10

benji127