WordPress multisite in subdirectory, not root, and remove base folder from url

I might be misreading but I can’t find a solution to the following need: I want to install WordPress in a subfolder of my www directory, let’s say www/wp. I then want to add two blogs to the multisite network called foo and bar. When I do so, they end up with the URL:

  • http://example.com/wp/foo
  • http://example.com/wp/bar

I would instead like them to be located at:

Read More
  • http://example.com/foo
  • http://example.com/bar

But I do not want a WP site running at the home/root:

  • http://example.com

Because I will be running a different application there (otherwise I would just install WordPress at the root and be done) with it.

How do I configure this?

Related posts

2 comments

  1. Install WordPress in its own directory. Follow the instructions on the link provided. You would need to install two WP files in the root directory – index.php and .htaccess. Those may or may not interfer with your existing web site.

  2. I recently tried to do the same and found a solution that worked for me.

    Firstly, have your multisite setup in a subdirectory:

    Second, add a directory in the root:

    In that newly created directory (/site1/), you can add a .htaccess to rewrite all requests to the multisite. I’m not an expert on this, but this code worked for me in the .htaccess file:

    RewriteEngine On RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_FILENAME} !-f
    
    RewriteRule ^(index.php)$ /multi/$1   
    
    RewriteRule ^(.*)$ /multi/$1
    

    WordPress still has lots of references in the database to your sub-subdirectory site1. So the next thing you should do is change all the entries in the database. You can use this script for that purpose.

    Now everything should be working, and when you visit http://www.mydomain.com/site1 you should see your multisite subsite. The only problem is that sometimes you cannot log in because of some cookie domain conflicts. To fix this, delete all the domain cookies (I used chrome dev tools). Secondly, add these lines to the wp-config.php file:

    define('ADMIN_COOKIE_PATH', '/'); 
    
    define('COOKIE_DOMAIN', '');
    
    define('COOKIEPATH', ''); 
    
    define('SITECOOKIEPATH', '');
    

    Hopefully it works for you.

Comments are closed.