1

UPDATE

When first posting this, I didn't understand the problem. When I removed the index.php from the urls with a .htaccess file (http://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html), all the templates other than the homepage all gave 404s.

ORIGINAL POST

I've create a list of the channel entries, but when you click on a link it sends you to the url example.com/title-permalink= and throws up a 404.

I've tried to visit the single entry pages by manually putting in the url but it doesn't work either.

Here's the simple code on the index page.

<ul>
   {exp:channel:entries channel="essays"}
      <li><a href="title-permalink="site/essay"}">{title}</a></li>
   {/exp:channel:entries}
</ul>

And the single entry page.

{exp:channel:entries channel="essays"}
   <h1>{title}</h1>
   {body}
{/exp:channel:entries}

I haven't had this problem before. It seems like it must be really simple. What am I missing? Something in the settings?

3

You are missing the opening { on the href's tag, and {title_permalink} has an underscore _ not a dash.

<li><a href="{title_permalink="site/essay"}">{title}</a></li>

See EE Docs on Permalinks

  • Thanks. Always the little things. The links now points to the right url (like example.com/site/essay/my-first-post) but the single entry page still doesn't come up. It gets a 404. – Nathaniel S Jun 20 '14 at 1:29
  • @Nathaniel do you have a site.group template folder with a essay.html template in it? – Bradley Flood Jun 20 '14 at 1:35
  • Yes, template group "site" and the templates "index" and "essay" within. – Nathaniel S Jun 20 '14 at 1:39
  • Is your .htaccess file configured? What happens when you visit /index.php/site/essay? – Bradley Flood Jun 20 '14 at 1:56
  • I only set up the .htaccess to remove index.php from the urls. I get a 404 when I visit index.php/site/essay. Actually I get a 404 when I try and visit any template other than the home page. Maybe that's the real problem... – Nathaniel S Jun 20 '14 at 13:34
0

On single entry pages that aren't throwing 404's EE is falling back to the template group's index.html page.

To fix:

Add this to the top of your detail page template. Adjust the segment to a number AFTER your URL Title displays:

{if segment_3 != ""}
  {redirect="404"}
{/if}

And on single entry pages you should do this to trigger 404's when EE can't find an entry so that it does not fallback to the index.html template in the template group. Adjust the segment to your URL Title segment:

{exp:channel:entries
  channel="ch_blog"
  limit="1"
  require_entry="yes"
  url_title="{segment_2}"
  status="open"
  disable="{gv_param_disable_default}"
  dynamic="no"
}

Finally, add these to your .htaccess file (where /index.php/site/404 points to your 404 template):

ErrorDocument 404 /index.php/site/404

<FilesMatch "(\.jpe?g|gif|png|bmp|css|js|flv)$">
  ErrorDocument 404 "File Not Found"
</FilesMatch>

That should do it!

  • 1
    Just curious - why turn dynamic off and force url_title on a single entry template? – Michael Boyink Jun 20 '14 at 12:08
  • I copied this code from a recent 2.8.1 project. For some reason "require_entry" was super finicky and wouldn't work without explicitly setting the URL title as a parameter. – Paulo Elias Jun 20 '14 at 16:26
  • It's not just the single entry pages, it's every single template other than the homepage. I went through the install, setup process again to figure this out. It's when I removed the index.php. ellislab.com/expressionengine/user-guide/urls/… With the problem better understood, I'm searching around for answers. – Nathaniel S Jun 23 '14 at 17:48
0

The real problem: After trying to remove the index.php from the urls with a .htaccess file (http://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html), all the templates other than the homepage all gave 404s. I looked around, tried lots of different versions of the .htaccess code, and this one it worked. https://expressionengine.stackexchange.com/a/871/3177

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

It worked on both my local build with MAMP and my hosting on Bluehost, both in sub-directories.

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.