getAll(); if ($all_redirects) { foreach ($all_redirects as $redirect_id) { $la_redirect = $GLOBALS['redirectsplugins']->getFields($redirect_id); $la_old_link = str_replace($siteurl, "", $la_redirect['old_link']); if ($actual_link == $siteurl . $la_old_link) { header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ' . $la_redirect['new_link'], true, 301); die(); } } // foreach } } // redirects_301_do_redirect function getUrl() { $url = @($_SERVER["HTTPS"] != 'on') ? 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : 'https://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; return $url; } // getUrl function redirects_301_options() { $redirects = new Redirects; $savedsuccesfully = false; if (isset($_POST['custom_id']) && isset($_POST['delete_custom'])) { $custom_id = sanitize_text_field($_POST['custom_id']); $redirects->remove($custom_id); die(); } if (isset($_POST['links_audit_submit']) && !isset($_POST['delete_custom'])) { $redirects->delete(); if (!empty($_POST['title'])) { $redirect_arr = $_POST['title']; foreach ($redirect_arr as $key => $redirect_title) { $title = sanitize_text_field($redirect_title); $section = sanitize_text_field($_POST['section'][$key]); $new_link = esc_url($_POST['new_link'][$key]); $old_link = esc_url($_POST['old_link'][$key]); $redirects->edit($title, $section, $new_link, $old_link); } } $savedsuccesfully = true; } ?>
Add your old path /old-path-from-site/ (don't forget to start with a forward slash) in the old link field, and the new path /new-path-somewhere/ in the new link field. If you're redirecting to an external URL add the https:// prefix.
Name and Section are there for your organization and convenience.
Please rate the plugin ★★★★★ to keep it free & maintained. It only takes a minute to rate. Thank you! 👋