How to redirect url from www.myapp.coto myapp.co? And also, if the URL has a different parameter, for example www.myapp.co/other-parameter, it will be redirected to myapp.co/other-parameterwhere it other-parametercan be any. Sorry for this noob question, I'm still 1 week in using Laravel.
By the way, I use a dynamic subdomain, so I only need to redirect www to non-www, and not to other subdomains.
Route::group(array('domain' => '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' => '{account}.myapp.co'), function() {
Route::get('/', function($account) {
if ($account == 'www') {
return Redirect::to('http://myapp.co');
}
return $account;
});
});
source
share