Feb 21, 2025
Brian
7min Read
Whether you’re creating a new link structure or migrating your WordPress site to a new domain, setting up 301 redirects in WordPress is necessary. This enables you to permanently move a web page to a new URL without losing its ranking power.
In this article, you will learn why 301 redirects are important for WordPress SEO and different methods to set them up – via hPanel, redirection plugins, a PHP script, or your site’s .htaccess file.
A 301 redirect is an HTTP status code sent by a web server to a browser, signaling that a web page has been permanently moved to a new location. When users try to access the old URL, they will be redirected to the new URL by default. This process helps preserve your website’s traffic, link equity, and overall SEO value.
Creating a permanent redirect, rather than a temporary redirect, brings several benefits to your WordPress website:
To create redirects automatically, use hPanel or a 301 redirection WordPress plugin.
For technically adept users, it’s also possible to set up 301 redirects by manually editing the site’s .htaccess file or creating a custom PHP script.
hPanel provides an intuitive interface for easy website management, including WordPress redirects.
If you’re a Hostinger user, follow these steps to set up a 301 redirect:

hPanel allows you to create multiple redirects – the list of existing redirects will appear at the bottom of the page. If you want to remove a 301 redirect, hit the Delete icon under Actions.
All in One SEO (AIOSEO) is a WordPress plugin that offers many features to improve search engine rankings and boost website traffic.
Those include an automated WordPress sitemap creation, content analysis tool, Google Search Console integration, and easy redirect manager.
Here’s how to create a 301 redirect with this popular SEO plugin:

Unfortunately, redirects are only available for licensed pro users. If you’re looking for a free solution, consider other WordPress redirection plugins.
301 Redirects is another recommended WP plugin to properly redirect users from the source URL to the new destination.
Besides creating a permanent 301 redirect, its free version also allows you to set up temporary 302 and 307 redirects:

If you’re comfortable writing code, manually editing the .htaccess file is another viable option.
Follow these steps to locate the .htaccess file in your site’s root folder and create a 301 redirect:
Redirect 301 /old-url/ https://www.example.com/new-url/
It’s also possible to move your old website to a new domain using a .htaccess redirect:
RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]Make sure to replace both olddomain.com and newdomain.com with your site’s domain names.
Advanced users can also create a PHP script to set up 301 redirects in WordPress. This method is useful for managing multiple redirects.
If you’re a Hostinger user, log in to hPanel and access your WordPress files via Websites → Dashboard → Files → File Manager. After that, follow these steps:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.example.com/new-url/");
exit();
?>To test whether the 301 redirect works, open your browser and type the address of your PHP script – it should look like this:
https://www.yourwebsite.com/redirects.php.
Remember that a slight typo or misspelling in the code can lead to website errors. Thus, always double-check your code and test the redirects thoroughly before deploying them.
As a precaution, it also pays to create a website backup to keep your files safe. With Hostinger’s managed WordPress hosting, you will get automated daily or weekly backups, depending on the chosen plan.

Each hosting package also comes with a free domain, unlimited SSL certificates, one-click WordPress installation, and LiteSpeed cache for improved performance. Plus, we have a rich library of WordPress tutorials, guiding you closer to online success.

When it comes to creating redirects, the 301 status code is not the only available option.
In this section, we’ll dive deeper into the key differences between a 301 redirect and other commonly used redirection codes.
A 301 redirect signals a permanent move from one URL to a different URL. This is particularly crucial for maintaining SEO equity and preserving user experience.
It’s the best choice when you’re certain that the change is permanent and you want to seamlessly transition visitors to the new location.
Unlike the permanent nature of the 301 redirect, a 302 redirect indicates a temporary URL move – the original URL will be restored at some point.
This type of redirect is beneficial when you need to perform maintenance or testing on the original page but plan to bring it back online later.
A 303 redirect is a specific type of redirect that indicates a resource can be found at another location. This is often used in response to a POST request made by a web browser.
Essentially, a 303 status code informs the client to make a GET request to retrieve the resource. A common scenario happens when a form submission redirects users to a different page.
Similar to the 302 redirect, a 307 redirect denotes a temporary move. It indicates that the resource being accessed has been temporarily moved to another location.
Implementing 301 redirects ensures a seamless user experience and maintains your website’s SEO rankings. Here are some scenarios where using 301 redirects is highly recommended:
When migrating to a new domain, restructuring your website, or simply updating your URLs, 301 redirects are pivotal in preserving user experience and maintaining SEO rankings.
If you’re a Hostinger user, it’s easy to create a 301 redirect via hPanel. Otherwise, there are various methods to set up 301 redirects in WordPress, such as:
Whatever method you choose, back up your website beforehand to avoid data loss if something goes wrong.
Have more questions about setting up a WordPress page redirect? Read through our FAQ section or simply leave a comment below.
Here are some commonly asked questions about a 301 redirect.
In short, yes. WordPress provides an easy way to create 301 redirects through plugins like AIOSEO and 301 Redirects. If you possess the technical know-how, it’s also possible to edit the .htaccess file or create a custom PHP script.
There are several reasons why your 301 redirect is not working as expected. One common issue is caching, where your browser stores the old website version. Clear your browser cache and any caching plugins you’re using. Also, double-check your .htaccess code and ensure there are no typos or syntax errors.
While 301 redirects are great for permanent changes, there are times when you might need temporary redirects. For this, consider using 302, 303, or 307 redirects. These can be beneficial when you’re testing new URLs or making temporary changes to your website.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.