correct URL redirect
Use the correct URL redirects when changing a site

As a website owner or administrator, you may sometimes need to change your site’s URL structure or move content to a new location. In such cases, implementing a proper URL redirect strategy is crucial to maintaining your search engine rankings and providing a seamless user experience.

In this post, we’ll discuss the importance of using the correct URL redirect methods, specifically HTTP redirects, and delve into trending research, outbound links, frequently asked questions, and examples to help you make the most of your URL redirection strategy.

Why use HTTP Redirects

1. Preserve Your SEO Rankings with the Right Redirects

When you change a website’s URL structure or move content, search engines need to understand the new location of the content to index it correctly. Implementing the right type of HTTP redirect (301 or 302) ensures that search engines update their index without affecting your rankings negatively.

Trending Research: A study by Moz ( ) shows that a well-implemented 301 redirect preserves almost all link equity, ensuring minimal impact on your SEO rankings.

2. Avoid Broken Links and Improve User Experience

Broken links can be frustrating for your visitors and damage your website’s credibility. Properly executed URL redirects ensure that users are seamlessly taken to the correct content, improving their overall experience.

Example: When The New York Times ( ) restructured their website, they used URL redirects to maintain user experience and ensure that old bookmarks and links still led to the appropriate content.

3. Simplify Site Migration and Rebranding

HTTP redirects are essential when migrating your site to a new domain or rebranding your business. By implementing the right redirect strategy, you can maintain your website’s SEO value and ensure that your users can easily find your new online presence.

Example: When Google acquired Waze ( ), they used URL redirects to ensure a smooth transition and maintain Waze’s existing search engine rankings.

4. Manage Affiliate and Campaign Links

URL redirects can also be used to manage affiliate and marketing campaign links. By creating custom redirects for different marketing channels, you can track their performance and gather valuable insights into your marketing efforts.

Example: Amazon ( ) uses URL redirects for its affiliate program, enabling affiliates to promote products using unique tracking links.

URL Redirect Techniques in WordPress

URL redirect techniques in WordPress are essential for various reasons, such as improving user experience, managing broken links, or implementing SEO best practices. Here are some common methods to create URL redirects in WordPress with their respective code:

  1. .htaccess file method (for Apache servers):

The .htaccess file is a server configuration file that can be used to create redirects. To use this method, follow these steps:

a. Connect to your WordPress site using an FTP client or your web hosting control panel’s file manager. b. Locate the .htaccess file in your site’s root directory. c. Open the file and add the following code to create a 301 redirect:

sqlCopy codeRewriteEngine On
RewriteRule ^old-url/?$ /new-url/ [R=301,L]

Replace old-url with the original URL (without the domain name) and new-url with the new destination URL. Save the file and upload it back to your server.

  1. Redirection plugin:

The Redirection plugin is a popular choice for managing URL redirects in WordPress. To use this plugin:

a. Install and activate the Redirection plugin. b. Go to your WordPress dashboard, then navigate to ‘Tools’ > ‘Redirection’. c. In the ‘Source URL’ field, enter the old URL you want to redirect. d. In the ‘Target URL’ field, enter the new destination URL. e. Click ‘Add Redirect’ to save the changes.

  1. Using PHP header function:

To create a redirect using the PHP header function, you can add the following code snippet to the top of your PHP file:

phpCopy code<?php

Replace with the new destination URL.

  1. Using WordPress wp_redirect function:

The wp_redirect function is a built-in WordPress function that helps you create redirects. To use this function, add the following code to your theme’s functions.php file or a custom plugin:

phpCopy codefunction custom_redirect() {
    if (is_page('old-url')) {
        wp_redirect('', 301);
add_action('template_redirect', 'custom_redirect');

Replace old-url with the original URL slug and with the new destination URL.

Link redirection

Remember to backup your website before making any changes to the code, and test the redirects thoroughly to ensure they are functioning correctly.

301 vs 302 Redirect: Which is Better for SEO

301 and 302 redirects serve different purposes, and their impact on SEO varies accordingly. Understanding the differences between these two types of redirects is essential for choosing the right one for your specific situation.

301 Redirect:

A 301 redirect is a permanent redirect, indicating that a webpage or resource has moved permanently to a new location. It’s commonly used when you are migrating a website to a new domain, restructuring URLs, or removing outdated content. A 301 redirect passes most of the original page’s SEO authority (link juice) to the new page, ensuring that the new page maintains its ranking in search engine results.


  • Preserves SEO authority from the original page
  • Ideal for website migrations, URL restructuring, or removing outdated content
  • Search engines eventually update their index to reflect the new URL


  • Inappropriate use can result in search engines deindexing the old URL
  • Takes time for search engines to update their index

302 Redirect:

A 302 redirect is a temporary redirect, indicating that a webpage or resource has moved to a new location for a short period. It is typically used when a page is undergoing maintenance or updates, and the original content is expected to be available again shortly. Unlike a 301 redirect, a 302 redirect does not pass the original page’s SEO authority to the new page. Search engines continue to index the original URL, considering the redirect temporary.


  • Maintains the original page’s SEO authority and ranking
  • Ideal for temporary changes, maintenance, or updates


  • Does not pass SEO authority to the new page
  • Inappropriate use can lead to search engines treating it as a 301 redirect, resulting in loss of SEO authority for the original page

Which is better for SEO? The better option for SEO depends on your specific situation. If you need a permanent change or want to pass the original page’s SEO authority to the new page, a 301 redirect is the better choice. However, if the change is temporary and you want to maintain the original page’s SEO authority, a 302 redirect is more appropriate.

Always use the correct redirect type for your specific scenario to ensure that you maintain your website’s SEO performance and avoid any negative impacts on your search engine rankings.

Redirect 404 to homepage

I tried this code, it doesn’t show 404 pages, but it shows the same URL but content of the homepage.

/*add this code in .htaccess file*/

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]


How to Redirect a Page with HTTP 301 in PHP

HTTP 301 Redirect is an SEO well disposed approach to divert perusers to a page’s new area. There are a lot of advantages of utilizing HTTP Redirect. These advantages can be found in the htaccess technique post. htaccess or PHP can be both utilized for sending 301 sidetracks. The htaccess technique can be found in How to Redirect Old Domain to New Domain Using htaccess Redirect. This post talks about the strategy that utilization php to produce the HTTP 301 Redirect.

As an example, we will redirect a page to in PHP.

Add this code snipped in function.php file Or at the end of header.php

// Permanent 301 redirection
header("HTTP/1.1 301 Moved Permanently");


Redirect http to https:

wordpress SSL setting

1. Redirect All Web Traffic

If you have existing code in your .htaccess, add the following:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$  [R,L]

2. Redirect Only a Specific Domain

For redirecting a specific domain to use HTTPS, add the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$  [R,L]

3. Redirect Only a Specific Folder

Redirecting to HTTPS on a specific folder, add the following:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$  [R,L]

WordPress Redirection Plugin:

Create and manage redirects quickly and easily without needing Apache or Nginx knowledge. If your WordPress supports permalinks then you can use Redirection to redirect any URL.

There is full support for regular expressions so you can create redirect patterns to match any number of URLs. You can match query parameters and even pass them through to the target URL.

The plugin can also be configured to monitor when post or page permalinks are changed and automatically create a redirect to the new URL.

Download from WordPress Resource: Click here 

Mohd Ozair

OzairWebs is a free WordPress and SEO resource Web Development company. The main goal of this site is to provide quality tips, tricks, hacks, and Web Development Services that allow WordPress beginners to improve their sites.