Implementing a 301 redirect in your .htaccess file (a textual content file for configuring features of internet sites hosted on Apache servers) is a helpful method to completely redirect one URL to a different in a means that preserves rating authority.
Utilizing .htaccess recordsdata to implement 301 redirects helps you to execute advanced patterns, like pattern-based redirects (redirects that mechanically match and ahead teams of comparable URLs utilizing a single rule).
When to Use a 301 Redirect
Use a 301 redirect any time it’s essential ship customers to a special web page and need to hold your site visitors and web optimization intact.
A few of the commonest eventualities for 301 redirects are whenever you’re consolidating duplicate pages into one important web page and whenever you’re migrating from HTTP to HTTPS.
Listed below are some others:
Fixing Key phrase Cannibalization
Implementing 301 redirects could be a good method to handle key phrase cannibalization: when a number of pages compete for a similar key phrase, which may harm your rankings.
Alex Meyerhans, CEO of Meyer Digital Media, recommends merging the content material into one web page and utilizing a 301 redirect to level the outdated web page to the brand new one when different optimization efforts haven’t labored:
Typically you may repair key phrase cannibalization by way of on-page optimization to de-optimize the web page that should not rank. And plenty of instances, that solves key phrase cannibalization. However typically it will not. Then, it is time to merge the content material from the offending web page into the specified one, and 301 that web page.
Preserving web optimization from Outdated Pages
Utilizing a 301 redirect to ship site visitors and search engines like google from outdated pages with robust backlinks to new pages is useful for sustaining the unique pages’ rankings.
web optimization Specialist Artturi Jalli shares an instance:
For those who had a ‘Black Friday 2024’ web page and now give attention to ‘Black Friday 2025,’ a 301 from the outdated to the brand new ensures hyperlink fairness and continuity.
Enhancing UX and web optimization for Tag or Class Pages
Redirecting default tag/class pages to curated touchdown pages can enhance web optimization and consumer expertise (UX).
Cameron Martel, Managing Companion at Monochrome Advertising and marketing and CMO of FutureFund, suggests doing this.
Tags/classes are sometimes featured prominently in web site UX (prime of posts, weblog feeds, and so forth.), however usually result in experiences which can be sub-optimal for rating. By 301ing these URLs to customized touchdown pages, we are able to higher management consumer expertise and enhance inner site visitors circulation to touchdown pages.
Deleting a Web page
For those who take away a web page out of your website, a 301 redirect sends guests to a associated web page to assist preserve the consumer expertise.
Nevertheless, if there’s no related web page to redirect guests to, it could be higher to serve a 404 or 410 as a substitute of deceptive Google and customers.
Find out how to Use a Internet hosting Panel to Set Up a 301 Redirect with an .htaccess File
Two widespread methods to arrange 301 redirects are by your internet hosting panel (like cPanel) or with a file switch protocol (FTP) shopper. The latter is extra superior.
We’ll stroll by utilizing cPanel.
1. Discover the .htaccess File
The .htaccess file is normally positioned within the root folder—the principle listing—of your web site.
To get there in cPanel, first click on “File Supervisor.”

Discover and open your website’s root folder (typically titled “public_html”).

Find your .htaccess file, proper click on, and choose “Edit.”

2. Edit and Save the .htaccess File
Redirects solely work if the rewrite engine (a function in Apache that permits redirects) is turned on.
Search for the next code close to the highest of the file. Or add it to your .htaccess file if it’s not already there:
RewriteEngine On
Then, write any redirect guidelines beneath “RewriteEngine On” however above “ (we’ll go over just a few choices later). And save the .htaccess file to use your redirects.
Find out how to Use a WordPress Plugin to Set Up a 301 Redirect with an .htaccess File
You’ll be able to entry your .htaccess file and arrange redirects immediately in WordPress utilizing a plugin so long as your website runs on Apache.
We’ll present how to do that utilizing the Yoast web optimization plugin.
1. Set up Yoast
Head to your plugins and seek for “Yoast.”
Click on “Set up Now” after which “Activate.”

2. Find Your .htaccess File
Yoast helps you to entry your .htaccess file inside your WordPress dashboard.
Go to “Yoast web optimization,” choose “Instruments,” and click on “File editor.”

3. Edit and Save the .htaccess File
Examine that the RewriteEngine is enabled and add the next code to your .htaccess file if not:
RewriteEngine On
Add your redirect guidelines earlier than the tag. You’ll be able to add a number of guidelines inside this block of code.
Then, click on “Save adjustments to .htaccess” whenever you’re achieved.

Frequent 301 Redirect Guidelines
Add these redirect guidelines into your .htaccess file to implement 301 redirects. Make certain to interchange the placeholder URLs with your individual.
Redirecting a Single URL
Add this 301 redirect to your .htaccess file if it’s essential redirect one web page to a different.
RewriteRule ^old-page/?$ https://www.yourdomain.com/new-page/ [R=301,L]
Redirecting a Single Folder
Use this rule when it’s essential redirect entire sections of your website (like redirecting “/weblog” to “/information”).
RewriteRule ^weblog/(.*)$ /information/$1 [R=301,L]
Redirecting WWW to Non-WWW URLs
Redirecting www to non-www URLs helps stop duplicate content material points by guaranteeing search engines like google don’t see www and non-www variations as separate pages with similar content material.
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*) https://yourdomain.com/$1 [R=301, L]
Redirecting a Web site to a New Area
Use this .htaccess rule to redirect your complete web site to a different area.
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 model of HTTP) is a rating issue, and forcing HTTP to HTTPS helps safe your website and enhance your web optimization.
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
Find out how to Examine Your 301 Redirects and Repair Points
Correct 301 redirects provide help to keep away from redirect chains and loops, damaged hyperlinks, and incorrect redirect sorts—like by accident utilizing a 302 redirect—which ends up in higher web optimization and a smoother expertise for customers.
Use Semrush’s Web site Audit software to test for redirect points. And hold your redirects working as supposed.
Configure Web site Audit and open your challenge.
Click on “Points” and search “redirects.”
Look beneath “Errors,” “Warnings,” and “Notices” to test in case your 301 redirects could be hurting your website. If there’s a difficulty, click on the quantity beside the issue for extra data.

Web site Audit additionally tracks every redirect you arrange. So that you don’t have to manually monitor every one—and threat forgetting some.
On the Web site Audit homepage beneath “Crawled Pages,” click on the quantity beside “Redirects.”

You’ll see an inventory of pages with redirects.

Double-check that every redirected web page is utilizing the right redirect kind. Corresponding to a 301 redirect for everlasting strikes as a substitute of a 302 redirect for momentary strikes.
Keep on High of Web site Points
Schedule common audits to obtain alerts at any time when you’ve got technical website points. So you may repair points and hold your web optimization robust.
Click on the gear icon and choose the “Schedule:” choice within the drop-down.

Choose how typically you’d just like the audit to run. And test the field subsequent to “Ship an e-mail each time an audit is full” if you need e-mail alerts. Click on “Save adjustments.”

Now, you don’t have to manually test or monitor redirects. Web site Audit does the heavy lifting for you.
Attempt Web site Audit right this moment.