title: Laravel route redirecting with data
body: <p>I have a basic route that looks like this:</p>
  
  <pre><code>Route::prefix('/group')-&gt;group(function () {
      // Some routes here
      Route::prefix('/{uuid}')-&gt;group(function () {
          // Some routes here
          Route::get('/user/{id}', 'Controller@preview')-&gt;name('view-user')-&gt;where('id', '[0-9]+');
      }
  }
  </code></pre>
  
  <p>The logic is that I want the <code>id</code> to be only numerical value. What I want to do now is, to declare a redirection to this, if the value is non-numerical. Let's say the input of <code>id</code> is <code>fs</code>. In that case I would want it to redirect to <code>id</code> with value <code>1</code>.</p>
  
  <p>I tried using <code>Route:redirect</code>, but could not make it work. It looks something like this:</p>
  
  <pre><code>Route::redirect('/group/{uuid}/user/{id}', '/group/{uuid}/user/1')-&gt;where('id', '[^0-9]+');
  </code></pre>
  
  <p>I would prefer to put the redirect inside the groups, but it can be outside if this is the only way. Any help will be greatly appreciated.</p>
  
  <p>What happens is, that I get a 404 error if I have the route redirect declared.</p>
  
  <p><strong>EDIT</strong>: I want to do it in the <code>routes/web.php</code> file. I know how to do it in the controller, but it is not what I need in the current case.
  Closures are not an option either, because that would prevent routes caching.</p>