Skip to content
Peripach.com
Menu
  • Home
  • Arts Entertainments
  • Auto
  • Business
  • Cryptocurrency
  • Digital Marketing
  • Education
  • Finance
  • Gaming
  • Health Fitness
  • Home Kitchen
  • Legal Law
  • Lifestyle Fashion
  • Medicine
  • Pets
  • Real Estate
  • Relationship
  • Shopping Product Reviews
  • Sports
  • Technology
  • Tours Travel
  • Privacy Policy
  • Contact US
  • Sitemap
Menu

How to Set Up 301 Redirects in an .htaccess File

Posted on June 3, 2025

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”).

A site's root folder opened by clicking "public_html" on File Manager.

Locate your .htaccess file, right click, and select “Edit.”

".htaccess" clicked and "Edit" selected from the window.

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.”

WordPress plugins library with "yoast" entered and "Install Now" clicked next to the Yoast SEO plugin.

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.”

"File editor" clicked from the "Tools" tab on Yoast SEO.

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.

Code entered along with redirect rules on the ".htacess file" window using Yoast SEO.

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’s 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. 

Issues tab on Site Audit with "redirects" entered and "4 redirect chains and loops" highlighted.

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.”

Site Audit Overview with the number next to Redirects under Crawled Pages clicked.

You’ll see a list of pages with redirects.

Crawled Pages on Site Audit showing a list of a domain's 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. 

The gear icon clicked and "Schedule:" selected from the drop-down on the Site Audit tool.

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.”

Scheduling frequency selected, "Send an email once an audit is complete" checked, and "Save changes" clicked on Site Audit settings.

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

Try Site Audit today.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Can Workplace harassment occur outside the office?
  • What is the purpose of a network vulnerability assessment?
  • Is Home Cleaning available for Airbnb homes?
  • Can layoffs affect a federally regulated employee?
  • Which suppliers join global sources trade show 2026?
  • 구글 검색 누락 AI 글 때문인가요?
  • Can customer success staffing agencies find remote talent?
  • 혼자 가도 강남달토는 부담 없는 곳일까?
  • 강남 가라오케 메뉴 뭐 있어요?
  • How do I rebuild confidence after online dating setbacks?
  • 강남호빠는 처음 방문 시 어떻게 하나요?
  • What problems are commonly fixed by Sub-Zero Repair Bay Area technicians?
  • Is severance pay Ontario different from termination pay?
  • Can the TikTok API collect geo-location data?
  • How do I know if I qualify for male boob reduction?
  • Are there premium mobile car cleaning services in Bristol?
  • What material is Airpod Charging Case made from?
  • Are commercial services available for Ductless AC in Coachella Valley, CA?
  • Decentralized Masters: Navigating the 2026 Market Cycle with Discipline
  • Can a Locksmith repair sliding door locks?

Archives

  • July 2026
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023

Categories

  • Arts Entertainments
  • Auto
  • Business
  • Cryptocurrency
  • Digital Marketing
  • Education
  • Finance
  • Gaming
  • Health Fitness
  • Home Kitchen
  • Legal Law
  • Lifestyle Fashion
  • Medicine
  • Pets
  • Real Estate
  • Relationship
  • Shopping Product Reviews
  • Sports
  • Technology
  • Tours Travel
Slot gacor
TOTO SLOT
Slot online
Slot
©2026 Peripach.com | Design: Newspaperly WordPress Theme