1

Hi I am fairly new to ExpressionEngine, but I am having an issue navigating from the Index Page. When ever I click on a link to view an entry it always gives me a 404 error.

I think it might be a configuration issue related to routing, but I am unsure. The message I get is as follows

The requested URL /~Streel/EE_Site/Shop/Test was not found on this server.

To my understand that structure is essentially the following:

/~UserAccount/Website/Channel/Entry

Is that correct? Also what information do I need to supply to help debug this issue?

Edit 1: Included Index Page

Below is what I am having the issue with, this is pretty much from the EE Tutorial here

The Goal is to show all Shops and link directly to each shop

<body>
    <p>This is my test platform to see how formating works</p>
    <br/>
    {exp:channel:entries channel='shop'}
     <h3><a href="{url_title_path='shop'}">{title}</a></h3>
      <p>{brewery_description}</p>
      {/exp:channel:entries}

</body>

Edit 2: More examples

Whenever I navigate to a non-home page TemplateGroup or Template, I get 404; (Each Template has a Hello World content in the web page)

  1. /~Streel/EE_Site/Locations/new -> 404 Response
  2. /~Streel/EE_Site/Locations -> 404 Response

Edit 3: Found a way to navigate

including index.php works

/~Streel/EE_Site/index.php/TemplateGroup/TemplateName works!

8
  • Sorry, I posted an answer and re-read the question, realised I'd mis-read! From the looks of it you have set up a template set up with a route, can you share the route settings for the template you're trying to see? Perhaps you can share where you got your 'understanding of the structure' too as a point of reference? – Blatant May 7 '15 at 8:47
  • Am I right that "~Strell" is actually your Unix username on the server? i.e. you're trying to access /home/Streel and that in there tyou have a directory with your site in it (EE_Site), and further from there Shop/Test are your 'channel/entry'? In EE Shop/Test means look for a template called Test in the template group Shop, unless you have a specific route set up (if you do could you share?) – Blatant May 7 '15 at 8:58
  • I just checked and my templates don't have any route settings in them, it's blank. /Test is supposed to be the Entry against the Channel I created. It's not a template – user6277 May 7 '15 at 10:41
  • Like I say, in EE segment1/segment2 map to template_group/template_name, NOT channel/entry. to get channel/entry you'd need to set up a route on a template (I'll answer this below). Can I just check, does /~Streel/EE_Site/ work, you get your homepage/index?? – Blatant May 7 '15 at 11:02
  • Yes that works as my index, well localhost/~Streel/EE_Site/ – user6277 May 7 '15 at 11:17
0

Thanks for the feedback, let me break this down somewhat. Firstly we have the server aspect of the URL you're using, namely /~Streel/EE_Site

This part of your URL is clearly routing to a folder in your home directory, if this part is not working this is a server configuration issue and is technichally out of scope of this StackExchange (but we'll help where we can!).

The next part will be the EE Path, here Shop/Test are broken down into 2 segments, as per the EE docs, without any special routes ( Docs : Template Routes ) these segments map to Template Group / Template Name. This isn't what you're after though! What you want is Channel/entry_url_title.

Note : You may wish to check out how EE uses Dynamic Parameters as well, might get you there quicker! however for completeness...

Note : from here on in I'm assuming your E version is > 2.9.3 so you have template routes!

No problem though, with the EE router we can set up a route on a template to handle this. For example lets set up a template in the Group called Site and a template called EntryDisplay.

Now lets edit the template and set the route. Here we go to the bottom, open up the "Access" section and in the "Template Route" field enter :

{desired_channel:alpha_dash}/{desired_entry:alpha_dash}

Also, Make sure 'Require All Segments' is set to 'Yes'. What we've done here is say if we have 2 segments (Shop and Test) and both are alpha_dash valid, use this template. Of course tyou'll have to review the routing table in Design -> Templates -> Template Route Manager to ensure this route is the last on in the list, or it'll try to handle all your 2 segment URLS!

Now for the template itself, on the template your segment/route variables are turned into standard EE variables ( so {segment:desired_channel} & {segment:desired_entry}), we can feed these into the good old EE Channel Entries tag as so :

{exp:channel:entries channel="{segment:desired_channel}" url_title="{segment:desired_entry}" dynamic="no"}
  <h1>{title}</h1>
  {!-- here we send to 404 land if there's no entry for the URL supplied! --}
  {if no_results} {redirect="404"} {/if}
{/exp:channel:entries}

Answer to Edit 1

Thanks for the further info, just looking at the code (I have a sandbox test set up) I can see 2 things that might be going wrong.

First is if you aren't getting your template displayed at /shop/, if the template group this is in is not called Shop this will never work, however you can re-use what we learned about routing above, simply set your template route to Shop and thats it! You should get your template appearing at /~Streel/EE_Site/Shop

Second is potentually the output of url_title_path is not correct. Really I'd need to see the output however I spunthis up on my local and essentually what it does is output {base_url} / {param1(shop)} / {url_title}

Therefore if the path before /shop/ is incorrect, please review your URL to the root directory of your site setting in Admin ->General Configuration, this should be 'localhost/~Streel/EE_Site'. If its the following parts, perhaps you can let us know the template group, template name and router setting so we can diagnose further...

Edit 2

Following investigation it appears the probelm was in fact using friendly URL's without having them set up. It seems the templates work fine when CStreel uses non freindly URL's i.e.

/~Streel/EE_Site/index.php/Shop/test

For info on setting up Freindly URL's, we refer again tothe EE docs : https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html

Here's my working example, it uses a whitelist principle so for any paths you wish to exclude from the friendly URL handling (apart from files and directories see inline comments) add them to the final 2 RewriteCond's :

# Enable Rewrite Engine
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Exclude file paths
    RewriteCond %{REQUEST_FILENAME} !-f
    #Exclude directory paths
    RewriteCond %{REQUEST_FILENAME} !-d
    #Cant rcall what this excludes, Pagination maybe?? 
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    #Specific files to exclude
    RewriteCond $1 !^(favicon\.ico|index\.php|path\.php|php\.ini|admin\.php) [NC]
    #Specific directories to exclude (bpath begins with)
    RewriteCond $1 !^(system|sysbase|images|themescss|assets)/ [NC]

    #If the current request is not excluded, insert the index.php
    RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

Finally, in order for EE to produce friendly url's from your tags, make sure to goto Admin -> General Preferences and set Name of your site's index page to '' (blank)

7
  • my version is 2.9.2 and I have template routes – user6277 May 7 '15 at 12:33
  • When following the Tutorial on Setting up Templates, Channels and Entries. I created the Home Template Group which I set as the default group, The page loaded fine. I then moved to the Simple Website Tutorial and created Channels, Channel Field Groups and Channel Fields to define my Data. After defining my Data it said to create Entries for my Channel 'Shops'. I created 3 "Test, "Lockhorn & "Neptune". – user6277 May 7 '15 at 12:45
  • I get a 404 when I navigate to "localhost/~Streel/EE_Site/Shop". But I have the Template created as a Blank Index Page – user6277 May 7 '15 at 12:49
  • the root URL is correctly set to localhost/~Streel/EE_Site – user6277 May 7 '15 at 12:53
  • ok cool, so lets get this right, if the template for /Shop/ is located the group called Shop and called index, you shouldn't need to route, if it's elsewhere you'll need to set its routeto Shop. Conversly if the template to view an individaual shop Shop/test will need the segment variable from the URL in order to work out which entry you need, so we use routing like above oy dynamics (also linked above). Please can you confirm the template groups and names for both the Shop listing and the individual shop template. – Blatant May 7 '15 at 13:20

Your Answer

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