0

I Have a MSM site setup, and am also using Structure.

The sub-site domains looks like: mymainsite.com/sub-site

The sub-site homepage loads just fine, but I cannot get to any pages after that - aka mymainsite.com/sub-site/anything gives me a 404.

I set up a template to try and see what's going on, and here's what I've found so far:

  • Entries from the Main Site seem to load fine.
  • Entries from the Sub Site 404
  • The site="" parameter does not seem to work with the structure nav tag.

Here's what I have for testing:

<p>Site: {site_name}</p>
<p>Breadcrumbs: {exp:structure:breadcrumb}</p>
<p>This NAV: {exp:structure:nav site="sub_site"}</p>
<p>Main Site NAV: {exp:structure:nav site="main_site"}</p>
<p>Structure Page URL: {structure:page:url}</p>
<p>Structure Page URI: {structure:page:uri}</p>
<p>Structure Child IDs: {structure:child_ids}</p>
<p>Structure Entry ID: {structure:top:entry_id}</p>
<h2>TEST Entries:</h2><br>
{exp:channel:entries site="sub_site"}
<p>{title} - {page_url} - {entry_id}</p>
<p><a href="{page_uri}">{page_uri}</a></p>
{/exp:channel:entries}

The output I get from http://mymainsite.com:

Site: [Correct Site Name]
Breadcrumbs: [BLANK]
This NAV: [Correct, Nav for Main Site]
Main Site NAV: [Correct]
Structure Page URL: [BLANK]
Structure Page URI: [BLANK]
Structure Child IDs: [BLANK]
Structure Entry ID: [BLANK]
TEST Entries: [BLANK]

The output I get from http://mymainsite.com/sub-site: (404 template)

Site: [Correct Site Name]
Breadcrumbs: Home > Here (home link is correct)
This NAV: [Correct Nav for Sub Site, BUT WRONG URLs, do not have /sub-site segment]
Main Site NAV: [WRONG - shows nav for Sub Site]
Structure Page URL: [Correct]
Structure Page URI: / (should be /sub-site ?)
Structure Child IDs: [BLANK]
Structure Entry ID: [BLANK]

TEST Entries: Homepage (incorrect - url is to the main site's homepage)

The output I get from http://mymainsite.com/page:

Site: [Correct Site Name]
Breadcrumbs: [BLANK]
This NAV: [Correct, Nav for Main Site]
Main Site NAV: [Correct]
Structure Page URL: [correct]
Structure Page URI: [correct]
Structure Child IDs: [BLANK]
Structure Entry ID: [correct]
TEST Entries: [BLANK]

The output I get from http://mymainsite.com/sub-site/page: (404 template)

Site: [WRONG - Main Site Name]
Breadcrumbs: [BLANK]
This NAV: [WRONG - Shows for Main Site]
Main Site NAV: [Correct]
Structure Page URL: [BLANK]
Structure Page URI: [BLANK]
Structure Child IDs: [BLANK]
Structure Entry ID: [BLANK]
TEST Entries: [Correct] - Lists all structure pages that exist under the Sub Site, correct {page_url} & {page_uri}, BUT the links all 404.

So the main issues I'm seeing is that the structure nav tag is not outputting the correct paths for the sub-site URLs as well. They're missing the /sub-site segment.

Any ideas what could possibly be going wrong here, or what I'm missing? I only have an htaccess file set up under the root, which contains:

<IfModule mod_rewrite.c>

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

</IfModule>

My directories are as follows:

Root -
- Main Site (is in root)
- images
- skin
- sub-site
- sub-site
- sub-site
System

Thanks for any insight!

1

You are not directing sub-site requests to your mymainsite.com/sub-site/index.php file, so a URI like this: mymainsite.com/sub-site/page is being rendered by your main mymainsite.com/index.php file, so it's being loaded by your main site.

In your main .htaccess file, you have to direct sub-site requests to the right bootstrap index.php.

So, your main .htaccess could look something like this:

RewriteCond %{REQUEST_URI} ^/sub-site [NC]
RewriteCond %{REQUEST_FILENAME} !sub-site/
RewriteRule ^(.*)$ sub-site/index.php [L]

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1 [R=301,NE,L]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

and you could add an .htaccess file to your sub-site folder that removes the index.php:

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule sub-site/index\.php/*(.*) sub-site/$1 [R=301,NE,L]

This is example is very untested, and I'm kinda asleep right now so my .htaccess foo is weak, but you get the point. If you monkey with it a bit (or Google around for the right rules) you should get it up and running.

Also, for your mymainsite.com/sub-site results, this part:

This NAV: [Correct Nav for Sub Site, BUT WRONG URLs, do not have /sub-site segment]

You must not have your settings correct in your sub-site index.php file. Review the MSM settings you must set in your sub-site index.php files and that should fix it:

https://docs.expressionengine.com/latest/msm/overview.html

So something like this should live near the top of sub-site/index.php

$assign_to_config['site_name'] = 'sub_site_shortname';
$assign_to_config['cp_url']    = 'http://mymainsite.com/system';
$assign_to_config['site_url']  = 'http://mymainsite.com/sub-site';

$system_path = '../system/';

I'm pretty out of it right now but this should get you pointed in the right direction. I haven't worked an MSM installation that used sub-folders instead of separate domains or sub-domains in a long time so I don't have any .htaccess files I can reference at hand, but your .htaccess file setup is a prime culprit of the misbehavior.

|improve this answer|||||
  • Thank you, there were a few issues going on but this lead me down the right path... appreciate the help! All working now :) – ByteMyPixel Jun 13 '19 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.