Editing a Wordpress Multisite Main Site URL

52 Views Asked by At

Some Context

I have a WordPress Multisite setup with Sub-Directories that looks like this :

  • dev.agency.xyz - (Main site URL)
  • dev.agency.xyz/pt/ - (Portuguese version of the site)
  • dev.agency.xyz/en/ - (English version of the site)

Both PT and EN are subdirectory site URL that will always start like this before adding the subpages URL.

Goal

The language of the main site URL is French and I would like to make sure the URL for the main site is constantly dev.agency.xyz/fr/ like the PT and EN sites. Let me give you an example of the current situation versus the expected results :

Current Situation

Here are some URLs from the main website :

  • dev.agency.xyz - Homepage URL
  • dev.agency.xyz/agency/ - Agency Page URL
  • dev.agency.xyz/wp-admin/ - WordPress Admin Dashboard URL

Note that for example that the EN site URLs looks like this :

  • dev.agency.xyz/en/ - Homepage URL
  • dev.agency.xyz/en/agency/ - Agency Page URL
  • dev.agency.xyz/en/wp-admin/ - WordPress Admin Dashboard URL

Expected result

I'd like to force the main site URL to behave like this :

  • dev.agency.xyz/fr/ - Homepage URL
  • dev.agency.xyz/fr/agency/ - Agency Page URL
  • dev.agency.xyz/fr/wp-admin/ - WordPress Admin Dashboard URL

The Problem

It seems that WordPress won't allow URL editing for the main site whereas for any subdirectory site added to the network, WordPress will allow URL editing.

What I've tried

I tried editing and adding a lot of things in wp-config.php but ended up leaving it as below because none of my modification were working as intended :

define( 'WP_DEBUG', false );

// Enable multisite
define( 'MULTISITE', true );
define( 'WP_ALLOW_MULTISITE', true );

// Define the network as a subdirectory
define( 'SUBDOMAIN_INSTALL', false );

define( 'DOMAIN_CURRENT_SITE', 'dev.agency.xyz' );
define('PATH_CURRENT_SITE', '/');
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

/* Ensure that connections work properly. */
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

Most of what I tried half or didn't worked when editing the .htaccess file, the only thing that seems to work is the code given in the WordPress Documentation which makes sure that dev.agency.xyz/fr/wp-admin leads to the admin dashboard of the main site, but still without remembering it :

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress

I think I'm trying to do something quite experimental, and I admit that it also confuses me when I'm confronted with the problem and looking for solutions. But hopefully I phrased this as clear as I could so you guys can lead me to the most adequate solution.

I'm not used to work on .htaccess files, so I might have missed something. But I am sure there is a way to make the links work fully as intended.

0

There are 0 best solutions below