WordPress.org

Ready to get started?Download WordPress

Forums

Multisite and Domain mapping media upload issue (5 posts)

  1. mbiven
    Member
    Posted 2 years ago #

    Multisite and Domain mapping media upload issue
    ===============================================

    When using the media uploader (browser and flash) domain mapping appears to be interfering with the rewrites that multisite uses for /files.

    subdomain.domain.com/files gets redirected to http://www.subdomain.com/files. That returns a 404 since its trying to load a page rather than getting redirect to the sites folder in blogs.dir.

    I'm in the process of upgrading the version of WordPress used, but cannot finish that until I've completed testing it against our internal WordPress plugins.

    I would like to know if this behavior is normal when using multisite and domain mapping together and if there is a simple fix that I can put into place before doing the WordPress upgrade.

    Multisite
    ---------
    domain.com
    then several sites as subdomains
    aaa.domain.com
    bbb.domain.com
    ccc.domain.com

    site options (using aaa.domain.com as example blogID of 2)
    domain aaa.domain.com
    Siteurl http://aaa.domain.com/
    Home http://aaa.domain.com/
    Upload Path wp-content/blogs.dir/2/files
    Fileupload Url http://aaa.domain.com/files

    Domain mapping
    --------------

    aaa.domain.com mapped to aaa.com, with aaa.com as primary
    bbb.domain.com mapped to bbb.com, with bbb.com as primary
    ccc.domain.com mapped to ccc.com, with ccc.com as primary

    Options enabled
    Remote Login
    Permanent redirect
    User domain mapping page
    Redirect administration pages to site's original domain

    Apache config
    -------------

    vhost for each site (domain.com, aaa.domain.com, bbb.domain.com, ccc.domain.com)

    servername is site name
    serveralias for any domains the site is mapped to
    htdocs for subdomains (aaa.domain.com, bbb.domain.com, ccc.domain.com) is a symlink back to domain.com's htdoc.

    Thanks,

    Michael

  2. subdomain.domain.com/files gets redirected to http://www.subdomain.com/files. That returns a 404 since its trying to load a page rather than getting redirect to the sites folder in blogs.dir.

    Not really. It's SUPPOSED to go to subdomain.com/files (it would be going to subdomain.domain.com/files without domain mapping, this is correct, expected behavior).

    What's in your .htaccess?

    Was it working BEFORE you mapped at subdomain.domain.com/files?

  3. you've also got a redirect to the www in there jacking things up.

  4. mbiven
    Member
    Posted 2 years ago #

    These are systems I've inherited so I cannot answer how it worked before domain mapping was enabled, but from the nature of our sites it *should* have always been there.

    We do have some sites that are mapped to subdomains.
    So aaa.domain.com is mapped to blah.aaa.com. To stop the domain mapping plugin from adding the www we edit the domain mapping plugin as show below. That is also the only place I see a redirect adding a www in either the .htaccess, apache vhosts, W3TC, domain mapping etc. For those sites we :

    domain_mapping.php
    starting at line 511

    $wpdb->suppress_errors( $s );
    $protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
    if ( $domain ) {
        if( $domain == 'blah.aaa.com' ||
            $domain == 'blah.bbb.com' ){
                $return_url[ $wpdb->blogid ] = untrailingslashit( $protocol.$domain );
        } else {
            $return_url[ $wpdb->blogid ] = untrailingslashit( $protocol.'www.'.$domain  );
        }

    .htaccess
    ---------

    # BEGIN W3TC Browser Cache
    <IfModule mod_deflate.c>
        <IfModule mod_setenvif.c>
            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
            BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
        </IfModule>
        <IfModule mod_headers.c>
            Header append Vary User-Agent env=!dont-vary
        </IfModule>
        AddOutputFilterByType DEFLATE text/css application/x-javascript text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
    </IfModule>
    <FilesMatch "\.(css|js)$">
        FileETag None
        <IfModule mod_headers.c>
             Header set X-Powered-By "W3 Total Cache/0.9.1"
        </IfModule>
    </FilesMatch>
    <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$">
        FileETag None
        <IfModule mod_headers.c>
             Header set X-Powered-By "W3 Total Cache/0.9.1"
        </IfModule>
    </FilesMatch>
    <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
        FileETag None
        <IfModule mod_headers.c>
             Header set X-Powered-By "W3 Total Cache/0.9.1"
        </IfModule>
    </FilesMatch>
    # END W3TC Browser Cache
    
    RewriteEngine On
    RewriteBase /
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ $1/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
  5. If you're using subdomains, then in PART it looks like your .htaccess was neevr updated to the 3.x version

    Below #END W3TC Browser Cache delete the rest and replace with

    # 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

Topic Closed

This topic has been closed to new replies.

About this Topic