ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

MSM - Problems with URL segments

October 27, 2011 6:31pm

Subscribe [2]
  • #1 / Oct 27, 2011 6:31pm

    UMstratcomm

    44 posts

    Greetings,
    I have recently installed MSM (Current Version: 2.1.1 - Build: 20111011; note that I am using EE 1.7, but I am using the 1.7-designated files that shipped with MSM), and I am in the process of setting up some new sites.  I have created a new directory for the site, copied the index.php and path.php files (and modified accordingly), set up the new MSM site, weblog, and templates.

    My default page displays fine, which leads me to believe that the path.php file is set up correctly;, however, any other page produces a 404 error (the 404 being displayed is from my original site’s designated 404 page).  I have a feeling that I am missing a simple setting.

    Here is my template:

    <html>
    <body>
    {if segment_2 == ""}
    <h1>This is the default index page.</h1>
    This page is displayed if segment_2 is empty.
    
    {/if}
    {if segment_2 != ""}
    <h1>This is the content page</h1>
    This page is displayed if segment_2 is NOT empty.
    
    {/if}
    
    </body>
    </html>

    The index page displays fine (for example, http://www.myserver.com/msm-directory/; the display is “This is the default index page…”), but if I attempt to view an entry (for example:  http://www.testserver.edu/msm-directory/entry_url_title), I get a 404 error.

    Can anyone share something obvious that I might be missing?  Perhaps a setting to double-check?

    Thank you,
    UMstratcomm

     

  • #2 / Oct 28, 2011 2:27pm

    Lisa Wess

    20502 posts

    Hi, UMstratcomm!

    Do you have a link to the site? I suspect you need to force query strings as per this FAQ entry.  You may need to change qtype as well.  There is an EE 1 specific section in there to run through, please let me know if any of that gets this working for you!

  • #3 / Oct 28, 2011 2:40pm

    Kevin Smith

    4784 posts

    Hi UMstratcomm,

    Another idea…

    I suspect there’s something wrong with your index.php removal technique. Could you disable .htaccess temporarily, insert index.php back into your URLs (under Admin > System Preferences > General Configuration), and try again? Are you still getting 404s?

    Also, where is your .htaccess located? Is it in the main domain’s web root or in the MSM directory’s web root? With the MSM site being a subfolder of the main domain, there could be some conflicts going on here.

  • #4 / Oct 28, 2011 3:05pm

    UMstratcomm

    44 posts

    Hi, UMstratcomm!

    Do you have a link to the site? I suspect you need to force query strings as per this FAQ entry.  You may need to change qtype as well.  There is an EE 1 specific section in there to run through, please let me know if any of that gets this working for you!

    Lisa, thanks for the reply.
    I tried forcing query strings on my MSM site, but it did not change anything.  I also tried changing the qtype on both my default, root-level index.php file, and on my subsite index.php file.  This did not work either.  I tried creating a third subsite, but get the same behavior.  Unfortunately, the site is on a development server and is protected by a firewall, but I am more than happy to share any code or output.

    Here is my main site’s .htaccess file (it resides at the server root - /; this site works fine):

    RewriteEngine On
    RewriteBase /
    
    rewritecond %{http_host} ^mainsitename.edu [nc]
    rewriterule ^(.*)$ <a href="http://www.mainsitename.edu/$1">http://www.mainsitename.edu/$1</a> [r=301,nc]
    
    # secure .htaccess file
    <Files .htaccess>
     order allow,deny
     deny from all
    </Files>
    
    # Dont list files in index pages
    IndexIgnore *
    
    # Simple 404 for missing files
    <FilesMatch "(\.jpe?g|gif|png|bmp)$">
      ErrorDocument 404 "File Not Found"
    </FilesMatch>
    
    #EE Rules
    
    
    
    #using the Inclusion Method (see link above); otherwise, SHIB auth will not work.
    #Note that you will need to add any new templage groups to this list.
    #The list is auto-generated at /eescripts/generate-template-groups
    RewriteCond $1 ^(member|rss|site|RED-Scripts|curators|default|Page_Elements|ums|eescripts|MEET-OUR-IMPACT|Navigation|park|president|totalrewards|info|search|forms|Dept_Embeds|help|LEADERSHIP|comments|ATYOURSERVICE|ENGAGE|STORIES|IMPACT|PS|P[0-9]{2,8}) [NC] 
    
    RewriteRule ^(.*)$ /index.php/$1 [L]

    Here is the subsite’s .htaccess file(it resides at /testfile/):

    # secure .htaccess file
    <Files .htaccess>
     order allow,deny
     deny from all
    </Files>
    
    # Dont list files in index pages
    IndexIgnore *
    
    # EE 404 page for missing pages
    ErrorDocument 404 /index.php?/
    
    # Simple 404 for missing files
    <FilesMatch "(\.jpe?g|gif|png|bmp)$">
      ErrorDocument 404 "File Not Found"
    </FilesMatch>
    
    RewriteEngine On
    
    RewriteBase /testsite/
    
    # remove the www
    RewriteCond %{HTTP_HOST} ^(www\.$) [NC]
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    # Add a trailing slash to paths without an extension
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule ^(.*)$ $1/ [L,R=301]
    
    # Remove index.php
    # Uses the "include method"
    # <a href="http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method">http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method</a>
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^/testsite/(test-group||members|P[0-9]{2,8}) [NC]
    RewriteRule ^(.*)$ /testsite/index.php?/$1 [L]
    
    # Remove IE image toolbar
    <FilesMatch "\.(html|htm|php)$">
      Header set imagetoolbar "no"
    </FilesMatch>

    Note that when I visit my subsite’s index page (http://mainsitename.edu/testsite/), it works fine.  When I visit any other page, specifically with anything typed in for segment_2, I get the following error:  Status: 404 Page Not Found.

    Everything on the root site has been working fine (it is a mirror of our production site; we have to add some extra sites and have installed MSM on our dev site).

    Any other thoughts or suggestions are appreciated, thanks!

  • #5 / Oct 28, 2011 3:09pm

    UMstratcomm

    44 posts

    Hi UMstratcomm,

    Another idea…

    I suspect there’s something wrong with your index.php removal technique. Could you disable .htaccess temporarily, insert index.php back into your URLs (under Admin > System Preferences > General Configuration), and try again? Are you still getting 404s?

    Also, where is your .htaccess located? Is it in the main domain’s web root or in the MSM directory’s web root? With the MSM site being a subfolder of the main domain, there could be some conflicts going on here.

    Kevin,
    I disabled both the root and subsite’s .htaccess files, then went and added index.php back to the subsite via the CP>General Config.  The subsite’s index page still works, but when I add something to segment_2, I get:

    Not Found

    The requested URL /testsite/test/ was not found on this server.

    I have an htaccess file in my main, root directory, and one in my subsite’s directory (along with an index.php and path.php file).

  • #6 / Oct 28, 2011 4:29pm

    Lisa Wess

    20502 posts

    I disabled both the root and subsite’s .htaccess files, then went and added index.php back to the subsite via the CP>General Config.  The subsite’s index page still works, but when I add something to segment_2, I get:

    What does your URL look like when you add something to segment 2?

  • #7 / Oct 28, 2011 4:34pm

    UMstratcomm

    44 posts

    I disabled both the root and subsite’s .htaccess files, then went and added index.php back to the subsite via the CP>General Config.  The subsite’s index page still works, but when I add something to segment_2, I get:

    What does your URL look like when you add something to segment 2?

    <a href="http://www.mainsitename.edu/testsite/test/">http://www.mainsitename.edu/testsite/test/</a>
  • #8 / Oct 28, 2011 4:41pm

    Lisa Wess

    20502 posts

    Ok, try with this:

    http://www.mainsitename.edu/index.php/testsite/test/

    if that doesn’t work, try:

    http://www.mainsitename.edu/index.php?/testsite/test/

    how’s that work?

  • #9 / Oct 28, 2011 4:48pm

    UMstratcomm

    44 posts

    Ok, try with this:

    http://www.mainsitename.edu/index.php/testsite/test/

    if that doesn’t work, try:

    http://www.mainsitename.edu/index.php?/testsite/test/

    how’s that work?

    They both produce the 404 File Not Found page from my top-level site.

  • #10 / Oct 30, 2011 6:44pm

    UMstratcomm

    44 posts

    It turns out that everything was configured correctly in my sub-site .htaccess and path.php files.  With enough testing, I was able to fix the problem:

    1) I used the PAGES module this time around, setting a fixed path and new, designated template for entries:

    <html>
    <body>
    {exp:weblog:entries site="testsite" weblog="testsection" limit="1"}
    <h1>{title}</h1>
    {body}
    
    {/exp:weblog:entries}
    
    </body>
    </html>

    2)When referring to URL segments, I changed segment_2 to segment_1, since the first URL segment outside of my designated path (http://www.servername.edu/testsite/xxx) is actually rendered as segment_1 (since my default site path is http://www.servername.edu/testsite). Not very logical…But yet it is.  😉


    Between those two changes, everything now appears to be working.

  • #11 / Oct 30, 2011 10:04pm

    Dan Decker

    7338 posts

    UMstratcomm,

    Glad to hear you were able to sort it all out, and thank you for sharing your solutions! If you need anything from us in the future, please let us know in a new thread.

    Cheers!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases