Answers.Body: <p>The route/template for '/itinerary/name-of-itinerary' will be defined in the section's settings, so it's the others you need to deal with.</p>
  
  <p>I'd add this route to your routes.php file:</p>
  
  <pre><code>'itinerary/(?P&lt;entrySlug&gt;[-\w]+)/(?P&lt;subpageSlug&gt;(dates-prices|gallery|etc))' =&gt; '_views/itinerary/index',
  </code></pre>
  
  <p>And then in '_views/itinerary/index' I'd include these conditionals:</p>
  
  <pre><code>{% if entry is not defined %}
      {% set entry = craft.entries.section('itineraries').slug(entrySlug).first() %}
  {% endif %}
  
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  
  <p>On your subpages, the entry model object won't be available by default so you need to check whether it's defined, and if not define it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-07T21:11:14.717Z
Answers.Text: Outstanding Jamie, thanks a lot. Totally makes sense now.
Answers.UserDisplayName: Ian Ebden
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-08T22:58:02.493Z
Answers.Text: This is also worth a read: http://buildwithcraft.com/docs/routing/   In your case, #6 would apply here: If you setup your template structure like your URLs, Craft will display the proper template based on the URL. Handy in some instances.
Answers.UserDisplayName: RitterKnight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-07T14:02:35.233Z
Answers.LastActivityDate: 2015-09-07T14:02:35.233Z
Answers.UserDisplayName: Jamie Pittock
Body: <p>I'm building a site with loads of complex itineraries. Entries are in a channel for various reasons, but I want to split the data across subpages, with a URL structure like:</p>
  
  <pre><code>/itinerary/name-of-itinerary
  /itinerary/name-of-itinerary/dates-prices
  /itinerary/name-of-itinerary/gallery
  /itinerary/name-of-itinerary/etc...
  </code></pre>
  
  <p>I want to route everything through my <code>_views/itinerary/index</code> template, and then just have a bunch of includes (dates-prices, gallery, etc...) in my index, something like:</p>
  
  <pre><code>{% include ( '_views/itinerary/' ~ craft.request.lastSegment ) %}
  </code></pre>
  
  <p>In my routes.php I've got:</p>
  
  <pre><code>'itinerary\/(?P&lt;slug&gt;[^\/]+)\/([^\/]+)'                 =&gt; '_views/itinerary',
  'itinerary\/(?P&lt;slug&gt;[^\/]+)'                           =&gt; '_views/itinerary',
  </code></pre>
  
  <p>So everything is routing fine to <code>_views/itinerary/index</code>. Trouble is, I get a 404 for anything other than <em>/itinerary/name-of-itinerary</em> because Craft uses the last segment to resolve the entry, which is exactly what you'd want normally. But if the last segment is 'dates-prices' or 'gallery' I'm screwed.</p>
  
  <p>Have I set this up right? Is there a more efficient and complete way? Any help much appreciated.</p>
  
Tags: <routes>
Title: Routes to fake a Structure
ThreadText: # Routes to fake a Structure
  
  (Asked by: username_0 on 2015-09-07)
  
  I'm building a site with loads of complex itineraries. Entries are in a channel for various reasons, but I want to split the data across subpages, with a URL structure like:
  
  ```
  /itinerary/name-of-itinerary
  /itinerary/name-of-itinerary/dates-prices
  /itinerary/name-of-itinerary/gallery
  /itinerary/name-of-itinerary/etc...
  
  ```
  
  I want to route everything through my `_views/itinerary/index` template, and then just have a bunch of includes (dates-prices, gallery, etc...) in my index, something like:
  
  ```
  {% include ( '_views/itinerary/' ~ craft.request.lastSegment ) %}
  
  ```
  
  In my routes.php I've got:
  
  ```
  'itinerary\/(?P<slug>[^\/]+)\/([^\/]+)'                 => '_views/itinerary',
  'itinerary\/(?P<slug>[^\/]+)'                           => '_views/itinerary',
  
  ```
  
  So everything is routing fine to `_views/itinerary/index`. Trouble is, I get a 404 for anything other than */itinerary/name-of-itinerary* because Craft uses the last segment to resolve the entry, which is exactly what you'd want normally. But if the last segment is 'dates-prices' or 'gallery' I'm screwed.
  
  Have I set this up right? Is there a more efficient and complete way? Any help much appreciated.
  
  **Tags:** routes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-09-07. Score: 3 | Accepted answer
  
  The route/template for '/itinerary/name-of-itinerary' will be defined in the section's settings, so it's the others you need to deal with.
  
  I'd add this route to your routes.php file:
  
  ```
  'itinerary/(?P<entrySlug>[-\w]+)/(?P<subpageSlug>(dates-prices|gallery|etc))' => '_views/itinerary/index',
  
  ```
  
  And then in '\_views/itinerary/index' I'd include these conditionals:
  
  ```
  {% if entry is not defined %}
      {% set entry = craft.entries.section('itineraries').slug(entrySlug).first() %}
  {% endif %}
  
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  On your subpages, the entry model object won't be available by default so you need to check whether it's defined, and if not define it.
  
  > **Comments:**
  > **username_0**: Outstanding username_1, thanks a lot. Totally makes sense now.  
  > **username_2**: This is also worth a read: http://buildwithcraft.com/docs/routing/   In your case, #6 would apply here: If you setup your template structure like your URLs, Craft will display the proper template based on the URL. Handy in some instances.  
  
  ---
  
  