htaccess Wildcard Subdomain – Setup for WordPress Multisite

.htaccessapache-2.4domain-name-systemwildcard-subdomainWordpress

I've installed a WordPress Network using subdomains on an existing install, to make an english version of my current site (in french), but I get a 404 error on the new subdomain site. If I create a subdomain myself via ftp the subdomain is found in the browser but wordpress doesn't see it (and if I've understood, wordpress doesn't need an actual subdomain folder as it will make a virtual one in the database).

I've tried modifying the DNS with help from someone on the WP forum (https://wordpress.org/support/topic/multi-site-install-original-site-is-fine-500-error-on-the-new-subdomain/) but no success so far; he suggested I try here. It seems likely the problem lies with the server (Apache/2.4.10 (Ubuntu)), but I can't access the server at my hosting company and the support there says they can't either, and that I should modify the htaccess.

I need to set up ideally a wildcard subdomain "*" or else a subdomain called "en" which will go to the folder where my wordpress install is, called "www". The wildcard subdomain was already set up in the DNS and should also be on the server, but I have no way of checking (or creating it).

What should I add to the htaccess to tell the server to send all subdomains to the wordpress install ? (Or alternately is there something else I should do ?)

Currently the htaccess contains this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress

These are my current DNS settings. "bobo" is a test subdomain.
DNS

Here is a screenshot of the server via ftp. The wordpress install is inside the www folder, according to the instructions from my host.
ftp

Let me know what other information you might need.

I am not a dev but I can modify the htaccess and upload it via ftp. I just have no clue what to write in it. I can modify the DNS as well, if necessary. My host (online.net) doesn't use CPanel. I have access to some admin tools on their site.

Any help is greatly appreciated.

Best Answer

For WordPress multi-site you don't want the subdomain to point to a subdirectory off the document root - which would seem to be the problem here. As you state in your question, you need the subdomain to point to the document root (the www subdirectory) where WordPress multi-site is installed.

All that is required is the * CNAME entry in DNS (which seems to already be configured from the information you linked to) and a wildcard entry in your server config of the form:

ServerAlias *.example.com

If the "wildcard" ServerAlias is not defined and you are forced to have subdomains that map to same-name subdirectories off the document root then that would seem to be the problem.


Just to reiterate what I mentioned in comments... you can't create subdomains using an FTP client. All you're doing is creating a subdirectory. If the host (online.net) is automagically mapping (wildcard) subdomains to subdirectories of the same name (off the document root) then this would seem to be unique to your host.

Related Topic