title: TYPO3 Extension - Redirect to another page in show action if no record is set or not available
body: <p>How can I redirect to another page when someone access the detail page but without a record or if record is not available?</p>
  
  <p>I have detail records like</p>
  
  <pre><code>domain.com/abc/ABC1234
  </code></pre>
  
  <p>When somone enters</p>
  
  <pre><code>domain.com/abc/
  </code></pre>
  
  <p>... I get:  </p>
  
  <pre><code>Uncaught TYPO3 Exception
  #1298012500: Required argument "record" is not set for Vendor\Extension\Controller\ActionController-&gt;show. (More information)
  
  TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException thrown in file
  /is/htdocs/www/typo3_src-8.7.11/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php in line 425. 
  </code></pre>
  
  <p>... in this case I want it to redirect to:</p>
  
  <pre><code>domain.com/other-page/
  </code></pre>
  
  <p>... I also need it if a specific record is not available.<br>
  ... how to do so?</p>
  
  <pre><code>/**
   * action show
   *
   * @param \Action $record
   * @return void
   */
  public function showAction(Action $record) {
  
      $this-&gt;view-&gt;assign('record', $record);
  
  }
  </code></pre>
  
  <p>Here are some examples <a href="https://stackoverflow.com/questions/40551408/typo3-extbase-redirect-to-pid">TYPO3 Extbase - redirect to pid</a> ... but not sure how to implement it</p>
  
  <p>Edit: What works is ...</p>
  
  <pre><code>/**
   * action show
   *
   * @param \Action $record
   * @return void
   */
  public function showAction(Action $record=null) {   
  
    if ($record === null) { 
      $pageUid = 75;
      $uriBuilder = $this-&gt;uriBuilder;
      $uri = $uriBuilder
        -&gt;setTargetPageUid($pageUid)
        -&gt;build();
      $this-&gt;redirectToUri($uri, 0, 404);
    } else {
      $this-&gt;view-&gt;assign('record', $record);
  
    }
  
  }
  </code></pre>