How do I maintain static directories on multisite subdomains?

I’m trying to migrate from multiple subdomain blogs to WP multisite. The one stumbling block is that I’m pretty sure the static files and directories on my subdomains will not be found; each of my blogs has its own set of static files (downloads, mp3 archives, scripts, etc.). What would be a way to maintain these?

Will the following work? I assume it will redirect anything with a . in it, no?

RewriteCond %{HTTP_HOST} ^sub\.domain\.org$
RewriteCond %{REQUEST_URI} \.
RewriteRule ^(.*)$ sub/$1 [R=301,L]

2 Answers
2

The standard WP RewriteRules ignore files and directories that “exist”. Example:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This the rewrite rule set for a WP install in the “root” of a site. Notice these two lines in particular:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

These set the conditions that the file or directory being referenced must not exist. Thus, only files/directories that Apache doesn’t find get rewritten to WordPress’s index.php file.

So if Apache finds the file and can serve it directly, then it will, and WordPress will not get involved. So static links should remain as they are as long as the files are in the same place as before.

Leave a Comment