Answers.Body: <p>This is not something built into Craft, but you could accomplish this with a plugin. You could have it run during your plugin's init function. On each page load, it would take the current page and load it into a <code>currentUrl</code> session variable. Then when you went to another page, the previous page url would move from <code>currentUrl</code> to a <code>prevUrl</code> session variable, and the current one would go into <code>currentUrl</code>.</p>
  
  <p>You would write a template variable to check and output them in your templates. You could possibly work with Craft's session flashes, but you would have to remember to tell it not to delete them when you grabbed them.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-30T20:37:03.317Z
Answers.LastActivityDate: 2014-06-30T20:37:03.317Z
Answers.UserDisplayName: Bryan Redeagle
Answers.Body: <p>I'd guess if this existed it would be available through craft.session. Unfortunately, I don't see any reference to a variable for the previous page's URL in the documentation for craft.session:   </p>
  
  <p><strong><a href="http://buildwithcraft.com/docs/templating/craft.session" rel="nofollow">http://buildwithcraft.com/docs/templating/craft.session</a></strong> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-30T20:34:02.493Z
Answers.LastActivityDate: 2014-06-30T20:34:02.493Z
Answers.UserDisplayName: Anna_MediaGirl
Answers.Body: <p>Was looking for an answer and came up with an noob alternative.</p>
  
  <p>On the paginated page (simplified):</p>
  
  <pre><code>&lt;a href="{{entry.url}}/p{{pageInfo.currentPage}}"&gt;{{entry.title}}&gt;&lt;/a&gt;
  </code></pre>
  
  <p>This will parse the page segment as the last segment of the entry. I first tried to use getSegment, but page numbers are seen as pagination url's and therefore ignored as segments. So, on the entry page if it's a paginated section for instance:</p>
  
  <pre><code>&lt;a href="/{{entry.section.handle}}/p{{craft.request.getPageNum()}}"&gt;back&lt;/a&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-12T10:06:26.020Z
Answers.LastActivityDate: 2018-02-12T10:06:26.020Z
Answers.UserDisplayName: noregt
Answers.Body: <p>The easiest way would be to check <a href="http://buildwithcraft.com/docs/templating/craft.request#urlReferrer">craft.request.urlReferrer</a> and see if they just came from the entry index page. If so, provide a link to send them back.</p>
  
  <pre><code>{% set referrer = craft.request.urlReferrer %}
  {% set indexBaseUrl = url('articles') %}
  
  {% if referrer and referrer|slice(0, indexBaseUrl|length) == indexBaseUrl %}
      &lt;a href="{{ referrer }}"&gt;Go back&lt;/a&gt;
  {% endif %}
  </code></pre>
  
  <p>Another, more explicit way to do it would be to actually pass the current page in the query string of the entry URLs, from the entry index page.</p>
  
  <pre><code>{% for entry in entries %}
      {% set url = url(entry.uri, { page: craft.request.pageNum }) %}
      &lt;a href="{{ url }}"&gt;{{ entry.title }}&lt;/a&gt;
  {% endfor %}
  </code></pre>
  
  <p>Then you could check for that “page” query string param in the single entry template:</p>
  
  <pre><code>{% set indexPage = craft.request.getQuery('page') %}
  {% if indexPage %}
      {% set indexUrl = url('articles/' ~ craft.config.pageTrigger ~ indexPage) %}
      &lt;a href="{{ indexUrl }}"&gt;Go back&lt;/a&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-30T22:00:55.303Z
Answers.LastActivityDate: 2014-06-30T22:00:55.303Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>While I know the back button does this perfectly well, I was wondering if there was a good way to "return to" a paginated page using a previous request or something? Wanting to do this server-side rather than relying on JS. Thanks.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-30T20:28:20.803Z
Comments.Text: Can you elaborate a bit? E.g. are you linking from a paginated entry listing to an entry's actual URL?
Comments.UserDisplayName: Brandon Kelly
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-30T20:47:21.423Z
Comments.Text: Precisely. A blog list view that is paginated. Say you're on pg 5 and choose an entry I want to go back to pg 5 with a text link on entry view versus just the blog landing page. Wasn't sure if it was in the request or session arrays or not. If not, I will make a small plugin.
Comments.UserDisplayName: Ryan Shrum
Tags: <pagination>
Title: Back to paginated page
ThreadText: # Back to paginated page
  
  (Asked by: username_0 on 2014-06-30)
  
  While I know the back button does this perfectly well, I was wondering if there was a good way to "return to" a paginated page using a previous request or something? Wanting to do this server-side rather than relying on JS. Thanks.
  
  **Tags:** pagination
  
  > **Comments:**
  > **username_1**: Can you elaborate a bit? E.g. are you linking from a paginated entry listing to an entry's actual URL?  
  > **username_0**: Precisely. A blog list view that is paginated. Say you're on pg 5 and choose an entry I want to go back to pg 5 with a text link on entry view versus just the blog landing page. Wasn't sure if it was in the request or session arrays or not. If not, I will make a small plugin.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2014-06-30. Score: 6 | Accepted answer
  
  The easiest way would be to check [craft.request.urlReferrer](http://buildwithcraft.com/docs/templating/craft.request#urlReferrer) and see if they just came from the entry index page. If so, provide a link to send them back.
  
  ```
  {% set referrer = craft.request.urlReferrer %}
  {% set indexBaseUrl = url('articles') %}
  
  {% if referrer and referrer|slice(0, indexBaseUrl|length) == indexBaseUrl %}
      <a href="{{ referrer }}">Go back</a>
  {% endif %}
  
  ```
  
  Another, more explicit way to do it would be to actually pass the current page in the query string of the entry URLs, from the entry index page.
  
  ```
  {% for entry in entries %}
      {% set url = url(entry.uri, { page: craft.request.pageNum }) %}
      <a href="{{ url }}">{{ entry.title }}</a>
  {% endfor %}
  
  ```
  
  Then you could check for that “page” query string param in the single entry template:
  
  ```
  {% set indexPage = craft.request.getQuery('page') %}
  {% if indexPage %}
      {% set indexUrl = url('articles/' ~ craft.config.pageTrigger ~ indexPage) %}
      <a href="{{ indexUrl }}">Go back</a>
  {% endif %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2014-06-30. Score: 4
  
  This is not something built into Craft, but you could accomplish this with a plugin. You could have it run during your plugin's init function. On each page load, it would take the current page and load it into a `currentUrl` session variable. Then when you went to another page, the previous page url would move from `currentUrl` to a `prevUrl` session variable, and the current one would go into `currentUrl`.
  
  You would write a template variable to check and output them in your templates. You could possibly work with Craft's session flashes, but you would have to remember to tell it not to delete them when you grabbed them.
  
  
  ---
  
  ### Answer by username_3 on 2014-06-30. Score: 2
  
  I'd guess if this existed it would be available through craft.session. Unfortunately, I don't see any reference to a variable for the previous page's URL in the documentation for craft.session:
  
  **<http://buildwithcraft.com/docs/templating/craft.session>**
  
  
  ---
  
  ### Answer by username_4 on 2018-02-12. Score: 1
  
  Was looking for an answer and came up with an noob alternative.
  
  On the paginated page (simplified):
  
  ```
  <a href="{{entry.url}}/p{{pageInfo.currentPage}}">{{entry.title}}></a>
  
  ```
  
  This will parse the page segment as the last segment of the entry. I first tried to use getSegment, but page numbers are seen as pagination url's and therefore ignored as segments. So, on the entry page if it's a paginated section for instance:
  
  ```
  <a href="/{{entry.section.handle}}/p{{craft.request.getPageNum()}}">back</a>
  
  ```
  
  
  ---
  
  