Implementing a 301 redirect in your .htaccess file (a text file for configuring aspects of websites hosted on Apache servers) is a useful way to permanently redirect one URL to another in a way that preserves ranking authority.Â
Using .htaccess files to implement 301 redirects lets you execute complex patterns, like pattern-based redirects (redirects that automatically match and forward groups of similar URLs using a single rule).
When to Use a 301 RedirectÂ
Use a 301 redirect any time you need to send users to a different page and want to keep your traffic and SEO intact.
Some of the most common scenarios for 301 redirects are when you're consolidating duplicate pages into one main page and when you're migrating from HTTP to HTTPS.
Here are some others:
Fixing Keyword Cannibalization
Implementing 301 redirects can be a good way to address keyword cannibalization: when multiple pages compete for the same keyword, which can hurt your rankings.Â
Alex Meyerhans, CEO of Meyer Digital Media, recommends merging the content into one page and using a 301 redirect to point the old page to the new one when other optimization efforts havenât worked:
Sometimes you can fix keyword cannibalization via on-page optimization to de-optimize the page that shouldn't rank. And many times, that solves keyword cannibalization. But sometimes it won't. Then, it's time to merge the content from the offending page into the desired one, and 301 that page.
Preserving SEO from Outdated Pages
Using a 301 redirect to send traffic and search engines from outdated pages with strong backlinks to new pages is helpful for maintaining the original pagesâ rankings.
SEO Specialist Artturi Jalli shares an example:Â
If you had a âBlack Friday 2024â page and now focus on âBlack Friday 2025,â a 301 from the old to the new ensures link equity and continuity.
Improving UX and SEO for Tag or Category Pages
Redirecting default tag/category pages to curated landing pages can improve SEO and user experience (UX).
Cameron Martel, Managing Partner at Monochrome Marketing and CMO of FutureFund, suggests doing this.
Tags/categories are often featured prominently in website UX (top of posts, blog feeds, etc.), but typically lead to experiences that are sub-optimal for ranking. By 301ing these URLs to custom landing pages, we can better control user experience and improve internal traffic flow to landing pages.
Deleting a Page
If you remove a page from your site, a 301 redirect sends visitors to a related page to help maintain the user experience.Â
However, if thereâs no relevant page to redirect visitors to, it might be better to serve a 404 or 410 instead of misleading Google and users.
How to Use a Hosting Panel to Set Up a 301 Redirect with an .htaccess File
Two common ways to set up 301 redirects are through your hosting panel (like cPanel) or with a file transfer protocol (FTP) client. The latter is more advanced.
Weâll walk through using cPanel.
1. Find the .htaccess File
The .htaccess file is usually located in the root folderâthe main directoryâof your website.
To get there in cPanel, first click âFile Manager.â

Find and open your siteâs root folder (often titled âpublic_htmlâ).

Locate your .htaccess file, right click, and select âEdit.â

2. Edit and Save the .htaccess File
Redirects only work if the rewrite engine (a feature in Apache that allows redirects) is turned on.Â
Look for the following code near the top of the file. Or add it to your .htaccess file if itâs not already there:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>Then, write any redirect rules below âRewriteEngine Onâ but above â</IfModule> (weâll go over a few options later). And save the .htaccess file to apply your redirects.
How to Use a WordPress Plugin to Set Up a 301 Redirect with an .htaccess File
You can access your .htaccess file and set up redirects directly in WordPress using a plugin as long as your site runs on Apache.
Weâll show how to do this using the Yoast SEO plugin.Â
1. Install Yoast
Head to your plugins and search for âYoast.âÂ
Click âInstall Nowâ and then âActivate.â

2. Locate Your .htaccess File
Yoast lets you access your .htaccess file within your WordPress dashboard.
Go to âYoast SEO,â select âTools,â and click âFile editor.â

3. Edit and Save the .htaccess File
Check that the RewriteEngine is enabled and add the following code to your .htaccess file if not:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>Add your redirect rules before the </IfModule> tag. You can add multiple rules within this block of code.
Then, click âSave changes to .htaccessâ when youâre done.

Common 301 Redirect Rules
Add these redirect rules into your .htaccess file to implement 301 redirects. Make sure to replace the placeholder URLs with your own.
Redirecting a Single URL
Add this 301 redirect to your .htaccess file if you need to redirect one page to another.
RewriteRule ^old-page/?$ https://www.yourdomain.com/new-page/ [R=301,L]Redirecting a Single Folder
Use this rule when you need to redirect whole sections of your site (like redirecting â/blogâ to â/newsâ).
RewriteRule ^blog/(.*)$ /news/$1 [R=301,L]Redirecting WWW to Non-WWW URLsÂ
Redirecting www to non-www URLs helps prevent duplicate content issues by ensuring search engines donât see www and non-www versions as separate pages with identical content.
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule ^(.*) https://yourdomain.com/$1 [R=301, L]Redirecting a Website to a New Domain
Use this .htaccess rule to redirect your entire website to another domain.
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]Redirecting HTTP to HTTPS
HTTPS (the encrypted version of HTTP) is a ranking factor, and forcing HTTP to HTTPS helps secure your site and improve your SEO.
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]How to Check Your 301 Redirects and Fix Issues
Proper 301 redirects help you avoid redirect chains and loops, broken links, and incorrect redirect typesâlike accidentally using a 302 redirectâwhich leads to better SEO and a smoother experience for users.
Use Semrush Site Audit tool to check for redirect issues. And keep your redirects working as intended.
Configure Site Audit and open your project.Â
Click âIssuesâ and search âredirects.âÂ
Look under âErrors,â âWarnings,â and âNoticesâ to check if your 301 redirects might be hurting your site. If thereâs an issue, click the number beside the problem for more information.Â

Site Audit also tracks each redirect you set up. So you donât need to manually track each oneâand risk forgetting some.
On the Site Audit homepage under âCrawled Pages,â click the number beside âRedirects.â

Youâll see a list of pages with redirects.

Double-check that each redirected page is using the correct redirect type. Such as a 301 redirect for permanent moves instead of a 302 redirect for temporary moves.
Stay on Top of Site Issues
Schedule regular audits to receive alerts whenever you have technical site issues. So you can fix issues and keep your SEO strong.
Click the gear icon and select the âSchedule:â option in the drop-down.Â

Select how often youâd like the audit to run. And check the box next to âSend an email every time an audit is completeâ if you want email alerts. Click âSave changes.â

Now, you donât need to manually check or track redirects. Site Audit does the heavy lifting for you.
Try Site Audit today.
