[resolved] Multisite and a main blog that has /files/ as upload directory (3 posts)

  1. Mark
    Posted 6 years ago #

    My main blog always has had root.com/files as upload directory.

    When installing multisite I discoved that a .htaccess rewrite rule also involves /files/ . This conflicts with the existing physical folder. Understandably, images and other uploads on my main blog don't work now.

    What is the best way to fix it? I understand I could relocate all existing files and go through the database to change all links in posts and all file locations for the Download Monitor downloads. I'm looking for an easier option though.

  2. Mark
    Posted 6 years ago #

    I seem to have found a solution. Just change the .htaccess rewriterule from

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


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

    i.e. add domain.com/ right after the regex wildcard and before files so that the regex only sends requests for files at *.domain.com/files/ to ms-files.php. Will this keep working with new uploads? I'll check.

  3. Mark
    Posted 6 years ago #

    Well no - it actually didn't work at all. But this does:

    Use the original rewrite rule suggested by multisite, but add a condition above it:

    RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    In prose: only carry out this rewrite rule when we are on a subdomain. (Obviously, I'm in a no-www setup, i.e. my main domain is at http://domain.com — otherwise I would've added www as an exception.)

Topic Closed

This topic has been closed to new replies.

About this Topic