Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Http\Response->redirect(string $url, int $httpStatusCode = 302): void
The new address/location to jump to
The redirection HTTP status code, 302 means it was temporary and 301 represents a permanent jump
Redirect a HTTP client to a new address/location. Set the redirect status code which indicates the type of jump, default is 302.
Calling this redirect method will automatically call $response->end('')
for you and will end the response.
<?php
$server->on('Request', function(OpenSwoole\Server\Request $request, OpenSwoole\Server\Response $response)
{
$response->redirect("https://openswoole.com/", 301);
});