What's the correct way of performing a server-side redirect in custom Concrete5 code (5.7+)?
            Asked
            
        
        
            Active
            
        
            Viewed 1,285 times
        
    2 Answers
3
            
            
        I discovered this is the best way:
(new RedirectResponse('/URL-HERE'))->send();          // 302 temporary
(new RedirectResponse('/URL-HERE', 301))->send();     // 301 permanent
You should be able to call this from (almost) anywhere within the app and not worry about namespaces since it has an alias in /concrete/config/app.php.
        Simon East
        
- 55,742
 - 17
 - 139
 - 133
 
3
            
            
        Another solution would be as follows:
$response = \Redirect::to('/URL-HERE');
$response->send();
exit;
or
return \Redirect::to('/URL-HERE')->send();
Sidenote: The url provided must not be absolute. For example: '/dashboard/reports/logs'
        toesslab
        
- 5,092
 - 8
 - 43
 - 62