00008 How to run Humhub as Main and other applications in subfolders

To install HumHub, Wikipedia (MediaWiki), and WordPress on a single domain where HumHub occupies the main directory, you will use a subdirectory structure. This setup allows example.com to lead to HumHub, while ://example.com and example.com/blog lead to the other applications. [1, 2, 3]

1. Preparation & File Structure

You must create separate folders for the secondary applications within your web server's root directory (usually /var/www/html/ or public_html/). [2]

  • Root Directory (/): Upload all HumHub files here.
  • Subdirectory 1 (/wiki): Create this folder for Wikipedia (MediaWiki).
  • Subdirectory 2 (/blog or /wp): Create this folder for WordPress. [2, 3, 4, 5, 6]

2. Database Configuration

Each application needs its own data storage. You have two options: [2]

  • Unique Databases (Recommended): Create three separate databases (e.g., humhub_db, wiki_db, wp_db) and three separate users for better security and isolation.
  • Shared Database: Use one database but assign a unique table prefix during each installation (e.g., hh, mw, wp_) to prevent data overlap. [2, 4, 7, 8, 9]

3. Step-by-Step Installation

  1. Install HumHub First: Upload the files to the root and run the HumHub Setup via example.com.
  2. Install WordPress: Upload WordPress files into your /blog folder. Access example.com/blog to start the WordPress installation wizard.
  3. Install MediaWiki: Upload MediaWiki files into your /wiki folder. Access ://example.com to complete the configuration. [2, 5, 10, 11, 12]

4. Critical Configuration: Handling .htaccess

Because HumHub is in the root, its .htaccess file (used for "pretty URLs") might interfere with subdirectories. [13]

  • Exclude Subdirectories: Open the .htaccess file in your root directory. Ensure there is a rule to prevent HumHub from trying to "handle" the wiki and blog folders.
  • Example Rule (for Apache):

RewriteEngine On RewriteCond %{REQUEST_URI} ^/(wiki|blog) [NC] RewriteRule .* - [L]

  • WordPress Permalinks: After installing WordPress, you may need to update its permalink settings in the dashboard to ensure ://example.com works correctly without conflicting with the root. [5, 14, 15, 16]

5. Summary Table

Application [12] URL Path Installation Location
HumHub example.com/ Root Folder (/public_html/)
MediaWiki ://example.com /public_html/wiki/
WordPress ://example.com /public_html/blog/

Do you need help with the specific Apache or Nginx configuration for these three apps to work together smoothly?

[1] https://serverfault.com [2] https://jetpack.com [3] https://docs.humhub.org [4] https://wiki.crowncloud.net [5] https://www.reddit.com [6] https://www.accuwebhosting.com [7] https://docs.humhub.org [8] https://runcloud.io [9] https://solidwp.com [10] https://docs.humhub.org [11] https://docs.humhub.org [12] https://www.atlantic.net [13] https://docs.humhub.org [14] https://wordpress.stackexchange.com [15] https://hueston.co [16] https://www.hostinger.com

Seeing a "Page Not Found" error

The reason you see a HumHub "Page Not Found" error is that HumHub’s routing rules are "greedy." The final lines in your .htaccess tell Apache: "If the request isn't a physical file, send everything to HumHub's index.php." Since /w/ and /b/ don't technically exist as single files, HumHub tries to process them as internal social network pages. To fix this, you need to tell the HumHub .htaccess to ignore those specific directories.

The Fix

Open your .htaccess file and find the section where the RewriteRules begin. You need to add two "exclusion" lines immediately before the final RewriteRule .? %{ENV:BASE}/index.php [L] line. Modify that section to look like this:

# ... previous rules ...

# 1. Skip rewriting for the WordPress and MediaWiki directories
RewriteCond %{REQUEST_URI} ^/(w|b)/ [NC]
RewriteRule ^ - [L]

# 2. Existing rule for physical files (Keep this)
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]

# 3. Final HumHub routing (This stays at the bottom)
RewriteRule .? %{ENV:BASE}/index.php [L]

Why this works:

  • RewriteCond %{REQUEST_URI} ^/(w|b)/ [NC]: This checks if the URL starts with /w/ (Wiki) or /b/ (Blog).
  • RewriteRule ^ - [L]: This tells Apache: "If the condition above is met, stop processing rules here and just go to that folder." This prevents the request from ever reaching the HumHub index.php at the bottom.

A Note on Permalinks

Once you apply this, your sub-apps should load. However:

  1. WordPress: Go to Settings > Permalinks and click "Save Changes" to generate a new .htaccess inside the /b/ folder.
  2. MediaWiki: Ensure your $wgScriptPath = "/w"; is set correctly in LocalSettings.php.

To get everything running smoothly, you need to configure each application to acknowledge it is living in a subfolder. Here are the specific configurations for MediaWiki and WordPress.

1. MediaWiki (/w/) Configuration

Open your LocalSettings.php file (located inside the /w/ folder) and ensure these variables reflect the subdirectory path:

The URL base path to the directory containing the wiki;

default is /wiki. Change this to /w if your folder is named 'w' $wgScriptPath = "/w";

This is the path for 'Pretty URLs' (e.g., montessori.rocks/wiki/Main_Page)

Note: This matches the 'Article Path' $wgArticlePath = "/wiki/$1";

The protocol and server name

$wgServer = "https://montessori.rocks";

Pro Tip: If you want users to see montessori.rocks/wiki/Page_Name instead of montessori.rocks/w/index.php?title=Page_Name, you will need a small .htaccess file inside the /w/ folder as well.

2. WordPress (/b/) Configuration

WordPress is usually good at detecting its home, but if you have trouble logging in or see broken images, add these lines to your wp-config.php file (located inside the /b/ folder):

define( 'WP_HOME', 'https://montessori.rocks' ); define( 'WP_SITEURL', 'https://montessori.rocks' );

Crucial Step for WordPress Permalinks:

  1. Log in to your WordPress dashboard (montessori.rocks/b/wp-admin).
  2. Go to Settings > Permalinks.
  3. Choose your preferred structure (e.g., "Post name").
  4. Click Save Changes. This forces WordPress to create its own .htaccess file inside the /b/ folder so it doesn't conflict with HumHub.

3. Verification Checklist

After updating the root .htaccess (with the exclusion rules we discussed previously) and these settings:

  1. Clear your browser cache or use an Incognito window.
  2. Test HumHub: Navigate to montessori.rocks/spaces (should load normally).
  3. Test WordPress: Navigate to montessori.rocks/b/ (should show your blog).
  4. Test MediaWiki: Navigate to montessori.rocks/w/ (should show the wiki home).

To enable "Short URLs" for MediaWiki (so your links look like montessori.rocks/wiki/Page_Name instead of montessori.rocks/w/index.php...), you need to create a new .htaccess file inside your /w/ folder.

1. The MediaWiki Subdirectory .htaccess

Create or edit /w/.htaccess and paste this in:

Enable Rewrite Engine

RewriteEngine On

Short URL for Wiki articles

RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

Redirect /w/ to /wiki/ (Optional but cleaner)

RewriteRule ^/?w/?$ %{DOCUMENT_ROOT}/w/index.php [L]

2. Update MediaWiki LocalSettings.php

For the rules above to work, your LocalSettings.php must have these exact lines:

$wgScriptPath = "/w"; // The actual folder on your server $wgArticlePath = "/wiki/$1"; // The "fake" URL users see in the browser

3. Final Root .htaccess Adjustment

Since we are using /wiki/ as the virtual path for your MediaWiki, make sure your main HumHub .htaccess (in the root) also ignores the /wiki/ path, or HumHub will try to grab those requests. Update that specific line in your root .htaccess to include the virtual wiki path:

Add 'wiki' to the exclusion list

RewriteCond %{REQUEST_URI} ^/(w|b|wiki)/ [NC] RewriteRule ^ - [L]

How it looks now:

  • HumHub: montessori.rocks/
  • WordPress: montessori.rocks/b/
  • MediaWiki: montessori.rocks/wiki/Main_Page

Are you seeing any "403 Forbidden" errors or "Internal Server Errors" after adding these files?

If yes follow the next steps.

If you are seeing 403 Forbidden or 500 Internal Server Errors, it usually means there is a permission conflict or a syntax error in how the .htaccess files are interacting. Let’s troubleshoot the most common causes for this setup:

1. The "Options" Conflict (Fixes 500 Error)

HumHub’s .htaccess often includes Options +FollowSymLinks. Some shared hosts forbid this and require Options +SymLinksIfOwnerMatch instead. If you have both or the wrong one, the server crashes. Fix: In your root .htaccess, ensure only one is active. Try commenting both out just to test:

Options +FollowSymLinks

Options +SymLinksIfOwnerMatch

2. The "RewriteBase" Issue

Since HumHub is in the root, it might be trying to apply its base path to the subfolders. Fix: Inside your /w/ and /b/ folders, ensure their respective .htaccess files explicitly set their own base.

  • In /b/.htaccess (WordPress): Add RewriteBase /b/
  • In /w/.htaccess (MediaWiki): Add RewriteBase /w/

3. Permission Errors (Fixes 403 Forbidden)

A 403 error usually means the web server (Apache) doesn't have permission to read the new folders or the .htaccess files inside them. Fix:

  • Ensure folders /w/ and /b/ are set to 755 permissions.
  • Ensure all files (especially .htaccess and index.php) inside those folders are set to 644.
  • Check that your root directory doesn't have a "Deny from all" rule that is cascading down.

4. The "Directory Index" Problem

If you visit montessori.rocks/w/ and see a 403, it might be because the server is looking for index.html instead of index.php. Fix: Add this line to the top of your root .htaccess:

DirectoryIndex index.php index.html

Quick Debugging Step:

To find out exactly which file is causing the error:

  1. Rename /w/.htaccess to /w/.htaccess_bak.
  2. Try to visit montessori.rocks/w/index.php directly.
  3. If it loads, the problem is inside the .htaccess you just renamed. If it still gives an error, the problem is either folder permissions or the root .htaccess is still interfering.

If the error persists do the following check

Which specific URL is giving the error, and does the error message say "Forbidden" or "Internal Server Error"?