Routing for WordPress Multisite with both subdomain and subdirectory

New to WordPress but finally got close to what i want. What I wanted was to use multisite with both sub domains and sub directories.

What i did:
– I setup wordpress multisite with subdomain option.
– I setup my domainname to allow wildcard subdomains
– I use the standard htaccess file for subdirectories (this fixed a css issue to diaplay sites with both subdomains and subdir correctly)
– After I create a new website I go to edit and add a subdirectorie to the url

The result:
The above steps allowed me to create websites like the list below:
– domain.com
– sub1.domain.com
– sub1.domain.com/en
– domain.com/en
– …

The problem:
All the websites display correctly, but the admin url for urls that have both sub domain and sub directories doesn’t seem to work (eg. “sub1.domain.com/en/wp-admin/”).

The solution?:
I think it can easily be fixed in the htaccess, mainly with changes to the standard line below:

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

Does anybody know how to rewrite the above line so the wp-admin can be accessed by domains that have both subdomains and subdirectories? Keep in mind that it also has to work for domains that only have a sub domain or sub directory.

Read more here: Routing for WordPress Multisite with both subdomain and subdirectory

Leave a Reply

Your email address will not be published. Required fields are marked *