Support » Installing WordPress » Multisite setup .htaccess question.

  • Resolved rpmtl22

    (@rpmtl22)


    When setting up a multisite installation I was presented with code to add to wp-config.ph as well as code to modify the .htaccess file.

    I’m prompted to “Add the following to your .htaccess file in {site path on server removed} , replacing other WordPress rules:”

    In the .htaccess file there was already the following:

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and
    # "END WordPress" are dynamically generated, and should
    # only be modified via WordPress filters. Any changes to # the directives between these markers will be
    # overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    Do I (A) replace ALL of this including the comments “# BEGIN WordPress” and ending with “/IfModule”?

    or do I (B) only relace the section with the code beginning with “IfModule mod” and ending with “/IfModule”?

    fwiw the multisite installation seems to be working fine, so perhaps replacing everything as per (A) was the correct thing to do.

    Thanks to anyone who can confirm I did the correct thing.

    Russell

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,
    I appreciate your question. Well I suggest you to go with option (B). the reason for this is given below.

    When adding code to your .htaccess file for a multisite installation in WordPress, you typically want to add the new rules within the existing WordPress block. So, you should not replace the entire block, including the comments and directives between “BEGIN WordPress” and “END WordPress.”

    In your case, you should only replace the section within the <IfModule mod_rewrite.c> block. Replace the existing rules related to WordPress within that block with the additional code provided for multisite setup.

    So, the correct approach is (B): only replace the section with the code beginning with “IfModule mod” and ending with “/IfModule.”

    Your updated .htaccess file should look something like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # Add your multisite rules here
    
    </IfModule>
    # END WordPress

    Make sure to keep the existing WordPress directives intact and only replace the relevant section for multisite. If your multisite installation is working fine after making these changes, it indicates that you did the correct thing.

    You can also follow this link for set up it properly – https://multilingualpress.org/docs/how-to-install-wordpress-multisite/

    Thread Starter rpmtl22

    (@rpmtl22)

    I corrected the .htaccess file so only the code within <ifModule mod_rewrite></ifModule) is replaced and everything still works. Hopefully this will avoid any problems moving forward.

    Thank you for your help 🙂

    Russell

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.