Answers.Body: <p>The way Retour works, it doesn't do anything until Craft throws a 404 error. Some other plugins do this as well.</p>
  
  <p>Your route is such that anything Craft can't find goes to your SPA; that means Craft never throws a 404, so these tools will not do anything.</p>
  
  <p>What I'd suggest doing is have this redirect happen via your web server.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-29T13:14:20.013Z
Answers.LastActivityDate: 2019-04-29T13:14:20.013Z
Answers.UserDisplayName: andrew.welch
Answers.Body: <p>I ended up making a 404 template (which in atuality is the SPA index file)</p>
  
  <p>This causes the Craft redirects to take effect, and have the SPA as a fallback route.</p>
  
  <p>This means in Production i don't need any such route. For development purposes i do, so i made a conditional route file (to avoid the debug 404 of Craft):</p>
  
  <pre><code> if(getenv('ENVIRONMENT') === 'dev') {
     return [
       '&lt;url:(?!api).*&gt;' =&gt; ['template' =&gt; '404']
     ];
   } else {
     return [];
   }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-29T08:31:28.450Z
Answers.LastActivityDate: 2019-04-29T08:31:28.450Z
Answers.UserDisplayName: Hyra
Body: <p>I have Craft set up to serve a single page Vue App (vue-cli) for all routes it can't match in the sections.</p>
  
  <pre><code>return [
    '&lt;url:(?!api).*&gt;' =&gt; ['template' =&gt; 'index'],
  ];
  </code></pre>
  
  <p>This works perfectly.</p>
  
  <p>However, I was hoping I could also use a Redirect manager plugin like Retour, Redirect Manager or Sprout Redirects.</p>
  
  <p>I tried them all but they only take effect when I disable the routing rule. </p>
  
  <p>How could I have both working together?</p>
  
Tags: <redirect><vue>
Title: Using a Redirect plugin in conjuction with a wildcard route
ThreadText: # Using a Redirect plugin in conjuction with a wildcard route
  
  (Asked by: username_0 on 2019-04-29)
  
  I have Craft set up to serve a single page Vue App (vue-cli) for all routes it can't match in the sections.
  
  ```
  return [
    '<url:(?!api).*>' => ['template' => 'index'],
  ];
  
  ```
  
  This works perfectly.
  
  However, I was hoping I could also use a Redirect manager plugin like Retour, Redirect Manager or Sprout Redirects.
  
  I tried them all but they only take effect when I disable the routing rule.
  
  How could I have both working together?
  
  **Tags:** redirect, vue
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-04-29. Score: 1 | Accepted answer
  
  The way Retour works, it doesn't do anything until Craft throws a 404 error. Some other plugins do this as well.
  
  Your route is such that anything Craft can't find goes to your SPA; that means Craft never throws a 404, so these tools will not do anything.
  
  What I'd suggest doing is have this redirect happen via your web server.
  
  
  ---
  
  ### Answer by username_0 on 2019-04-29. Score: 1
  
  I ended up making a 404 template (which in atuality is the SPA index file)
  
  This causes the Craft redirects to take effect, and have the SPA as a fallback route.
  
  This means in Production i don't need any such route. For development purposes i do, so i made a conditional route file (to avoid the debug 404 of Craft):
  
  ```
   if(getenv('ENVIRONMENT') === 'dev') {
     return [
       '<url:(?!api).*>' => ['template' => '404']
     ];
   } else {
     return [];
   }
  
  ```
  
  
  ---
  
  