• Hiya everyone,

    I’m duplicating my original post at https://premium.wpmudev.org/forums/topic/correct-htaccess-in-wpms-3x
    Thought this might be interesting for guys over here as well ??

    OK, got a question about .htaccess in WP/WPMS 3.x

    After I do a clean install of WP 3.x and enable network my .htaccess looks like this:

    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]

    When I upgrade from WPMU I’m asked to update only 1 rule, so my .htaccess looks like this:

    RewriteEngine On
    RewriteBase /
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [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]
    
    <IfModule mod_security.c>
    <Files async-upload.php>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </Files>
    </IfModule>

    Both differ quite a lot ??
    My question here – what variant is correct for WPMS 3.x? Or do both do the same job?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Which is correct? Well one is for an upgraded WPMU install, and one is for new 3.0 installs that enable the network.

    If you upgrade from MU, you will always have that longer one. You will never go through the process of enabling the network because you’re already running a network.

    WordPress can tell. This is one of the ways it does that.

    they both ultimately do the same job in different way. But if you have a new install, you get the shorter rules. Don’t mix them up or all hell breaks loose.

    Thread Starter VentureMaker

    (@venturemaker)

    Hey Andrea,

    Thanks for clarifications.

    Well, I played with my local test WPs and MUs and after upgrading from MU to WP 3.x I just deleted old .htaccess and uploaded the shorter one. It worked well ??

    In another case I ‘upgraded’ old .htaccess file so that I got a longer one as a result. It also worked well :))

    Alright, as long as both are fine for WP 3.x (regardless if it’s a new or upgraded install) I’ll be using a shorter one from now and on ??

    Thanks again.

    You can’t mix the wp-config files though (just for clarifications).

    good to know on the htaccess. (that last if module isn’t wp-specific anyway)

    Oh, and nice to see you around. ??

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    FWIW, that last if module is for when you’re having annoying problems with http errors when uploading files via the flash uploader on WordPress. And it doesn’t always work ??

    The top (shorter) .htaccess file looks like the one for subdomains. The bottom (longer) one looks like the one for subfolders. And yes, they’re different. If you have hinky things happen with the shorter one on subfolders, switch and see if it works better with the longer ??

    Hey, I was just coming in here to point out that different htaccess files get generated differently depending on subdomains or subfolders. ??

    tag team wins again.

    Thread Starter VentureMaker

    (@venturemaker)

    @ipstenu

    FWIW, that last if module is for when you’re having annoying problems with http errors when uploading files via the flash uploader on WordPress. And it doesn’t always work ??

    Yup, I know ?? Right now I’m troubleshooting that nasty ‘HTTP error’ with flash uploader on one of my installs.

    The top (shorter) .htaccess file looks like the one for subdomains. The bottom (longer) one looks like the one for subfolders. And yes, they’re different.

    Really?
    Looking at two separate fresh installs – one subdirs, another subdomains – and both .htaccess’es are equal. And short ??

    @andrea_r

    You can’t mix the wp-config files though (just for clarifications).

    Yes, I’ve noticed that already.
    I always change lots of things in both fresh and upgraded configs manually.
    So far I have noticed that upgraded subdomains configs have:

    define('VHOST', 'yes');
    $base = '/';
    define('DOMAIN_CURRENT_SITE', 'domain.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOGID_CURRENT_SITE', '1');

    And fresh subdomains configs have:

    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', 'domain.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    Seems, after I upgrade from WPMU I can’t replace the first one with the second one – although that would be logical IMHO ??

    Oh, and nice to see you around. ??

    Thanks! We’ve been relocating recently, you may imagine time, costs and efforts involved ?? Anyway, I’m back to WP world now ??

    Hey, I was just coming in here to point out that different htaccess files get generated differently depending on subdomains or subfolders. ??

    I’ll double (tripple) check this, but for some reason I’m now looking at 2 absolutely equal .htaccess’es where one is originating from fresh subdomains install and another one – from fresh subdirs install.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I don’t think the upgrade changes the .htaccess, truth be told, which would account for some differences. I put the standard .htaccess in my MU upgraded to 3.0 and it worked fine.

    As for the config file, the only difference would be the three lines:

    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);

    Which I think you can add in without issues. Still, glad you’re running!

    Thread Starter VentureMaker

    (@venturemaker)

    @ipstenu

    I don’t think the upgrade changes the .htaccess, truth be told, which would account for some differences.

    It does not.
    Upgrade procedure from WPMU to WP instructs to change only 1 rule in .htaccess
    One should manually change this:
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
    into this:
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

    And, as far as I remember, WPMU’s .htaccess has been always the same in subdirs and subdomains installs.
    And seems it’s still the same in clean WPMS subdirs and subdomains installs.

    As for the config file, the only difference would be the three lines:

    define(‘WP_ALLOW_MULTISITE’, true);
    define(‘MULTISITE’, true);
    define(‘SUBDOMAIN_INSTALL’, true);

    Which I think you can add in without issues. Still, glad you’re running!

    Well, I tried replacing the whole blocks and that gave me errors on both fresh and upgraded installs.
    Minor things, I know ?? Just making sure I’m not omitting something important ??

    As for the config file, the only difference would be the three lines:

    define(‘WP_ALLOW_MULTISITE’, true);
    define(‘MULTISITE’, true);
    define(‘SUBDOMAIN_INSTALL’, true);

    Which I think you can add in without issues. Still, glad you’re running!

    Heck no! remember those other threads? ??

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    *gleep* Yes, don’t screw with it if it’s running ??

    Thread Starter VentureMaker

    (@venturemaker)

    What other threads? ??

    another user was having issues upgrading because they kept putting in the new declarations. two epic threads becasue they did it twice, a month apart. ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Correct .htaccess in WP(MS) 3.x’ is closed to new replies.