diff --git a/docker/README.md b/docker/README.md index 7d7a384a..ebeee0ba 100644 --- a/docker/README.md +++ b/docker/README.md @@ -133,7 +133,9 @@ docker run \ -e DISABLE_TRACK_PARAM="no-track" \ -e DELETE_SHORT_URL_THRESHOLD=30 \ -e VALIDATE_URLS=false \ - -e "NOT_FOUND_REDIRECT_TO=https://www.google.com" \ + -e "INVALID_SHORT_URL_REDIRECT_TO=https://my-landing-page.com" \ + -e "REGULAR_404_REDIRECT_TO=https://my-landing-page.com" \ + -e "BASE_URL_REDIRECT_TO=https://my-landing-page.com" \ -e "REDIS_SERVERS=tcp://172.20.0.1:6379,tcp://172.20.0.2:6379" \ -e "BASE_PATH=/my-campaign" \ shlinkio/shlink diff --git a/module/Core/src/Action/RedirectAction.php b/module/Core/src/Action/RedirectAction.php index d27bc0ad..31fdb1a3 100644 --- a/module/Core/src/Action/RedirectAction.php +++ b/module/Core/src/Action/RedirectAction.php @@ -7,14 +7,10 @@ namespace Shlinkio\Shlink\Core\Action; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; -use Shlinkio\Shlink\Core\Options; use Zend\Diactoros\Response\RedirectResponse; class RedirectAction extends AbstractTrackingAction { - /** @var Options\NotFoundRedirectOptions */ - private $redirectOptions; - protected function createSuccessResp(string $longUrl): Response { // Return a redirect response to the long URL. diff --git a/module/Core/src/Response/NotFoundHandler.php b/module/Core/src/Response/NotFoundHandler.php index 57e9fef4..6bf245c1 100644 --- a/module/Core/src/Response/NotFoundHandler.php +++ b/module/Core/src/Response/NotFoundHandler.php @@ -23,8 +23,8 @@ use function rtrim; class NotFoundHandler implements RequestHandlerInterface { - public const NOT_FOUND_ERROR_TEMPLATE = 'ShlinkCore::error/404'; - public const INVALID_SHORT_CODE_ERROR_TEMPLATE = 'ShlinkCore::invalid-short-code'; + public const NOT_FOUND_TEMPLATE = 'ShlinkCore::error/404'; + public const INVALID_SHORT_CODE_TEMPLATE = 'ShlinkCore::invalid-short-code'; /** @var TemplateRendererInterface */ private $renderer; @@ -72,10 +72,8 @@ class NotFoundHandler implements RequestHandlerInterface ], $status); } - $notFoundTemplate = $routeResult->isFailure() - ? self::NOT_FOUND_ERROR_TEMPLATE - : self::INVALID_SHORT_CODE_ERROR_TEMPLATE; - return new Response\HtmlResponse($this->renderer->render($notFoundTemplate), $status); + $template = $routeResult->isFailure() ? self::NOT_FOUND_TEMPLATE : self::INVALID_SHORT_CODE_TEMPLATE; + return new Response\HtmlResponse($this->renderer->render($template), $status); } private function createRedirectResponse(RouteResult $routeResult, UriInterface $uri): ?ResponseInterface diff --git a/module/Core/test/Response/NotFoundHandlerTest.php b/module/Core/test/Response/NotFoundHandlerTest.php index de15e81e..8f1d6f51 100644 --- a/module/Core/test/Response/NotFoundHandlerTest.php +++ b/module/Core/test/Response/NotFoundHandlerTest.php @@ -130,13 +130,13 @@ class NotFoundHandlerTest extends TestCase { $request = ServerRequestFactory::fromGlobals(); - yield [$request, NotFoundHandler::NOT_FOUND_ERROR_TEMPLATE]; + yield [$request, NotFoundHandler::NOT_FOUND_TEMPLATE]; yield [ $request->withAttribute( RouteResult::class, RouteResult::fromRoute(new Route('', $this->prophesize(MiddlewareInterface::class)->reveal())) ), - NotFoundHandler::INVALID_SHORT_CODE_ERROR_TEMPLATE, + NotFoundHandler::INVALID_SHORT_CODE_TEMPLATE, ]; } }