Views 144
How to redirect a page in WordPress with plugin, without plugin with server

How to redirect a page in WordPress with plugin, without plugin with server: Here’s a simple guide on how to redirect a page in WordPress. What is a redirect?
A redirect is a way to send visitors from one URL to another. It’s useful for changing page locations, moving websites, or fixing broken links.
Table of Contents
Ways to Redirect Pages:
- Using a Plugin
- Using Code
- Using a Hosting Panel (like cPanel/hpanel)
Redirecting Pages on the Same Site
If you’re redirecting pages within the same website, using a plugin or adding code is usually sufficient. For redirecting from one domain to another (site-to-site), you’ll need to use your hosting panel, such as cPanel or Hostinger, since domain-level redirects are different from page redirects.
how to redirect a page in wordpress with plugin
There are several free plugins available for redirection, but here are two recommended options:
- Redirection Plugin: Install and set up the plugin. You simply add the old URL and the destination URL to create a redirect.
- Rank Math SEO Plugin: This free SEO plugin has a redirection option in its dashboard. After enabling the redirection feature, you can easily add new URLs in the provided fields.
- Go to dashboard
- if u enabled redirections in rankmath you will find redirections in left nav, see below image


Some SEO plugins also offer premium versions with advanced redirection options.
Read my latest posts here:
- Responsive Chatbot Window with Clean UI/UX—Made with React & Next. js
- Hero Design Template – Design Agency
- Design Agency Hero UI Design with Elementor Pro Template 🚀
- Footer with Elementor Pro for free
- Top 3 Freemium UI Libraries
How to redirect one page to another page with code
If you prefer to add a redirect manually using code, follow these steps:
- Tip: Before making changes to your code, create a child theme to ensure your updates aren’t overwritten during theme updates.
- Inside your child theme’s folder, locate the
functions.php
file and add the following code: Code Example 1:
// Example of redirecting a page
function quadlayers_redirect() {
if (isset($_SERVER['HTTPS']) &&
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$currenturl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currenturl_relative = wp_make_link_relative($currenturl);
error_log("Current URL: " . $currenturl_relative); // Log current URL
switch ($currenturl_relative) {
case '/old-url/':
$urlto = home_url('/new-url/');
break;
default:
return;
}
error_log("Redirecting to: " . $urlto); // Log redirection URL
if ($currenturl != $urlto)
exit(wp_redirect($urlto));
}
add_action('template_redirect', 'quadlayers_redirect');
You can use these redirections for not-found pages regularly.
Example:-2
// Multiple URL redirections
function redirect_page() {
// Check for HTTPS and set the protocol
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
// Get the current URL
$currenturl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currenturl_relative = wp_make_link_relative($currenturl);
// Define the redirection map
$redirection_map = array(
'/about/' => '/contact-us/'
);
// Check if the current URL needs to be redirected
if (array_key_exists($currenturl_relative, $redirection_map)) {
$urlto = home_url($redirection_map[$currenturl_relative]);
// Perform the redirection if the current URL does not match the target URL
if ($currenturl != $urlto) {
wp_redirect($urlto, 301);
exit; // Make sure to exit after the redirection
}
}
}
add_action('init', 'redirect_page');
Video Example
Explanation of video: if you see here, i am entering https://thefallen.in/about/ and its redirecting to https://thefallen.in/contact-us/
You can also try multiple urls inside the array,
Redirecting from One Domain to Another
To redirect an entire domain or a page from one domain to another, you’ll need access to your hosting panel (e.g., cPanel or Hostinger). Domain-level redirections are set up differently from page-level redirects.
I will explain how to do in hostinger panel.
Step: 1 – Go to hostinger dashboard
Step 2: Go to the domain section.
Step 3: Find redirect features.


For example, in Hostinger’s cPanel, there’s an option for “Redirects,” where you can add the source domain and target domain for a site-wide redirect.
This is how you can manage page and domain redirection in WordPress!
Hire me here: My Profile
Give me a tip if you like. Gumroad profile Purchase any product add a tip there.