• Resolved AlexeyKosov

    (@alexeykosov)


    I have WordPress installed in a subfolder of the main site: https://www.mysite.com/blog/
    Now I need to add second blog on https://www.mysite.com/blog/second/
    So 2 blogs should work on the following URLs:
    https://www.mysite.com/blog/
    https://www.mysite.com/blog/second/

    I configures WordPress and almost everything works fine, but I have a little issue with the main blog (https://www.mysite.com/blog/), the post URLs look like /blog/blog/hello-world/ rather than /blog/hello-world/.
    Second blog URLs work properly.

    I tried to change permalink structure in site settings to /%postname%/, and all URLs look good after that, but all they cause 404 error.

    How can I get rid of double /blog mention in this case? Thanks in advance!

    wp-config settings:

    /* Multisite */
    define( 'WP_ALLOW_MULTISITE', true );
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', 'www.mysite.com');
    define('PATH_CURRENT_SITE', '/blog/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    htaccess:

    RewriteEngine On
    
    RewriteBase /blog/
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I configures WordPress and almost everything works fine, but I have a little issue with the main blog (https://www.mysite.com/blog/), the post URLs look like /blog/blog/hello-world/ rather than /blog/hello-world/.

    Sure, because that’s how Multisite works with subfolders.

    There’s a KIND of work around.

    Go to Network Admin -> Sites -> (root site) Permalink Structure -> /%postname%/

    Or whatever you want it to be.

    Keep in mind, if your permalinks refresh that will restore the /blog/ folder.

    Google “wordpress multisite remove blog from permalinks” if you want to see all the drama about this.

    Thread Starter AlexeyKosov

    (@alexeykosov)

    Did you read my message carefully?

    I tried to change permalink structure in site settings to /%postname%/, and all URLs look good after that, but all they cause 404 error.

    The solution was to clear WordPress internal rewrite rules with

    function flush_site_rules(){
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
    }
    add_filter("wp_loaded","flush_site_rules");

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Site Settings and Network Admin -> Site -> Settings may not mean the same thing. I’m good, but not a mind reader ?? So It pays for me to be specific.

    Be very careful with that flush. It may actually force revert you back to using /blog/ (especially should you visit the permalinks settings on the per-site permalink page).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multisite permalinks for subfolder wordpress installation’ is closed to new replies.