title: Redirect www to non-www in Laravel with URL parameters
body: <p>How can I redirect URL from <code>www.myapp.co</code> to <code>myapp.co</code> ? And also if the URL has other parameter like <code>www.myapp.co/other-parameter</code> will be redirected to <code>myapp.co/other-parameter</code> where the <code>other-parameter</code> can be anything. Sorry for this noob question, I am still 1 week in using Laravel.</p>
  
  <p>BTW, I am using dynamic subdomain so I need only the redirect www to non-www and not the other subdomains.</p>
  
  <pre><code>Route::group(array('domain' =&gt; 'myapp.co'), function() {
  
      Route::get('/', function() {
          return 'Hello! Welcome to main page...';
      });
      Route::get('/login', function() {
          return 'Login';
      });
      Route::get('/signup', function() {
          return 'Signup';
      });
  
  });
  
  Route::group(array('domain' =&gt; '{account}.myapp.co'), function() {
  
      Route::get('/', function($account) {
  
          if ($account == 'www') {
              return Redirect::to('http://myapp.co');
          }
          return $account;
      });
  
  });
  </code></pre>