WordPress multisite wildcard redirect .htaccess example

Steps to make a WordPress MU wildcard redirect work (using subdomains):

Cpanel -> Subdomains -> Add subdomain -> Subdomain: * . mywebsite.com, document root /public_html

Then add this code to your .htaccess file:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ – [L]
RewriteRule . index.php [L]

# END WordPress


Problem: After migrating to another server I had a strange problem with a dot after the domain name and the subdomains not working. This turned out to be server misconfiguration (on a shared host), if you have that problem read here.

Problem: I have experienced WP multsite main domain working, but all of the subdomain sites not loading when trying other solutions like “redirect” checking www and wildcard (*) in Cpanel. This technique uses subdomain instead of redirect. This happens to be on a dedicated server, but can also exist in a VPS or shared hosting.

Leave a comment