1

I have a problem with one template after enabling Strict URLs - it returns 404 instead displaying content from the channel named News. The URL to open that template is like http://www.mydomain.com/index.php/news/

Template code:

    {embed="includes/header_main"}
    {embed="includes/header_two_column"}
<div id="wrapper">
  <div id="content">
            <div id="content_main">
                      {if segment_2 == ''}
                         {exp:channel:entries channel="news"}
                            <h1 class="orange">{title}</h1>
                            {news_summary}
                            <a href="/index.php{page_uri}">Read more</a>
                            <br /><br /><br />
                         {/exp:channel:entries}
                    {if:else}
                         {exp:channel:entries channel="news"}
                            <h2 class="bigorange">{title}</h2>
                            {news_body}
                            <p><a href="/index.php/nm">Back to news</a></p>
                         {/exp:channel:entries}
                    {/if}
                    </div>
            <div id="content_sub_buttons">
                <div style="background-image: url(/uploads/images/doc_photo.png); width:212px; height: 199px;">
                <div style="padding-top: 12px; padding-left: 15px;">
                {exp:ce_cache:escape}
                {exp:random_number min="1" max="6"}
                <img src="/uploads/images/kids/{random_number_0}.png">
                {/exp:random_number}
                {/exp:ce_cache:escape}
                </div>
                </div>
            </div>
            <div class="clear">&nbsp;</div>
        </div>
        {embed="includes/footer"}

Any clue why is not loading that template?

Thanks

  • Please, what is the URL you're trying to open? – Robson Sobral May 30 '13 at 16:43
  • An example of URL added to the OP – JackTheKnife May 30 '13 at 16:48
1

Strict URL is working exactly how it is supposed to for you. From the EE blog:

With Strict URLs disabled, it’s possible to visit http://example.com/about-us/ and view that content. But you can also visit http://example.com/site/about-us/ and get the exact same content. This flexibility can be advantageous, but it comes with a price: dual availability can cause search engines to lower the content’s ranking.

With ExpressionEngine 2.6 and up, Strict URLs will be enabled by default in new installations. Using the same example, http://example.com/site/about-us/ is the only valid URL for that content. Visiting http://example.com/about-us/ with Strict URLs enabled will trigger ExpressionEngine’s defined 404 behavior.

If you have site/news as a template and strict URLs enabled, you can't access the news template with index.php/news. You have to have index.php/site/news.

UPDATE

Can you see if this does anything for you? Change your complex conditional to two simple conditionals:

{if segment_2 == ''}news home{/if}
{if segment_2 != ''}news listing{/if}
| improve this answer | |
0

In your example of http://www.mydomain.com/index.php/news/ you need to make sure that news is set as you default template group and that it contains a template called index. Otherwise you have to explicitly declare the template_group/template in the URL.

| improve this answer | |
  • Well, it looks like I have a problem with default template group, which has all-in-one catch-all /site/ group for all templates, including index and news. When I use http://www.mydomain.com/index.php/site/news/ it works as should. In that case I have used .htaccess RewriteRule to point to proper URL for that one case. – JackTheKnife May 30 '13 at 19:01
  • So site is your Default Group and you have ticked Make the index template in this group your site's home page?? If not then you'll need to do this or specify the template along with the template group. – Ian May 30 '13 at 19:25
  • Which version of EE is this btw? – Ian May 30 '13 at 19:25
  • Correct - 'site' is a default template group and 'index' template is a home page there. – JackTheKnife May 30 '13 at 19:35
  • I'm on EE 2.5.4 – JackTheKnife May 30 '13 at 21:05

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.