title: Laravel default route for subdirectory in a route group with prefix
body: <p>I have a route group for the prefix <code>admin</code>. I want that if the URL <code>http://www.example.com/admin/</code> is entered it by default loads the login page residing at <code>http://www.example.com/admin/login</code>. The login page is actually a controller, but I don't mind if the <code>admin/</code> redirects to <code>admin/login</code> or routes to its controller directly. From other answers I saw here it seems that redirection is better to make sure links are not messed up.</p>
  
  <p>I have tried various solutions with both routing and redirection, including the solution suggested <a href="https://stackoverflow.com/questions/23582354/laravel-4-default-route-for-route-group">here</a> but I am alwas getting Error 404. What is the recommended proper way to achieve this?</p>
  
  <p>My route group looks like this:</p>
  
  <pre><code>Route::group(array('prefix' =&gt; 'admin', 'namespace' =&gt; 'MyNamespace\Controllers\Admin'), function()
  {    
      //the following work fine
      Route::get('login', array('uses' =&gt; 'AdminLoginController@showLogin'));
      Route::post('login', array('uses' =&gt; 'AdminLoginController@doLogin'));
      Route::get('logout', array('uses' =&gt; 'AdminLoginController@doLogout'));
  
      //other resource routes for the respective admin pages
  });
  </code></pre>
  
  <p>Outside the route group I added the following, so that even <code>http://www.example.com/admin</code> without the trailing slash goes to the login page, which works fine.</p>
  
  <pre><code>Route::get('admin', function() { return Redirect::to("admin/login"); });
  </code></pre>
  
  <p>The problem is with <code>http://www.example.com/admin/</code> that is giving Error 404. I tried all the following (separately obviously), and none works. All of them were inside the route group.</p>
  
  <pre><code>    Route::get('/', function() { return Redirect::to("admin/login"); });
  
      Route::get('', function() { return Redirect::to("admin/login"); });
  
      Route::get('/', function() { return Redirect::to("login"); });
  
      Route::get('', function() { return Redirect::to("login"); });
  
      Route::get('/', array('uses' =&gt; 'AdminLoginController@showLogin'));
  
      Route::get('', array('uses' =&gt; 'AdminLoginController@showLogin'));
  </code></pre>
  
  <p>I also tried this outside the route group:</p>
  
  <pre><code>    Route::get('admin/', function() { return Redirect::to("admin/login"); });
  </code></pre>
  
  <p>None of them work. What is the right way to set a default route for a route group with a prefix subdirectory?</p>