• Resolved Mark

    (@codeispoetry)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Mark

    (@codeispoetry)

    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]

    to

    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.

    Thread Starter Mark

    (@codeispoetry)

    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.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multisite and a main blog that has /files/ as upload directory’ is closed to new replies.