Magento 2 – Change Logout Redirect Link to External Page

customerlogoutmagento-2.1magento2redirect

After logging out from the account the user is redirected to a page that redirects to the CMS home page of magento.
I don't have that page and want to redirect to an external page instead.
But I can't find a clean way to change that redirect url to a page outside of magento.
I want to redirect to my page root whereas magento resides in https://www.mymagento.com/shop/.
The redirect should lead to https://www.mymagento.com/.

Best Answer

Override the logout phtml template and update the redirect url.

vendor/magento/module-customer/view/frontend/templates/logout.phtml:14

Change the $block->getUrl() to the url where you want to be redirected.

$($.mage.redirect("<?php /* @escapeNotVerified */ echo $block->getUrl() ?>", "assign", 5000));