Change link in menu on condition

One option to do this involves using the CSS display property. Simply add two instances of your menu link, one with the home URL and one with the URL for all other pages. The idea is to hide the one you don’t want on pages you want the other to show, never showing both on any page.

In your CSS, add two rules that target these particular menu items. Each menu item will be an <li> element with multiple classes. Each will have a unique class that looks something like menu-item-1982.

Assuming your theme has the WP body classes enabled (verify by inspecting the HTML <body> tag) you can show/hide the correct menu item with code similar to this:

.home .menu-item-1982 { display: inline-block; }
.home .meun-item-1983 { display: none; }

This example will show menu item 1982 on the home page and hide 1983.

To hide 1982 on all pages but the home page, and to show 1983 on all pages but the home page, add a default state reversing the display property without the .home body class prefix.