This guide explains how to create a 301 redirect using the .htaccess file on your web server, including practical examples.

A 301 redirect is a permanent redirect informing search engines and browsers that a page has moved to a new location. It’s essential for SEO, preserving link equity, and improving user experience when URLs change.

To find the .htaccess file:
The .htaccess file is typically located in the root directory of your website (e.g., /public_html/). You can access and edit it through:

  • cPanel File Manager
  • FTP client (like FileZilla)
  • SSH (if applicable)

Note: Always back up your .htaccess file before making changes.

To create a 301 Redirect:
Open the .htaccess file and add the redirect rules. Below are common examples.

  1. Redirect a Single Page
    Redirect from one page to another:

    Redirect 301 /old-page.html https://www.example.com/new-page.html
  2. Redirect Entire Domain to a New Domain
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^oldsite\.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.oldsite\.com [NC]
    RewriteRule ^(.*)$ https://www.newsite.com/$1 [L,R=301,NC]
  3. Redirect Non-www to www
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
  4. Redirect HTTP to HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

Tips for Using 301 Redirects

  • Use them sparingly and only when URLs have permanently changed.
  • Incorrect redirects can lead to redirect loops or broken SEO.
  • Test redirects after saving using browser or online tools (e.g., httpstatus.io).

Setting up a 301 redirect through .htaccess is a simple but powerful way to manage URL changes and maintain SEO value. Be sure to test your redirects and keep a backup of your original file in case you need to revert.

Find more information about: What is a URL Redirect and How does it Function

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

Outlook Express e-mail issues

Unable to receive/send e-mails – For incoming mail server –Tool>Accounts>Mail>Properties>Servers The incoming mail server(POP3) should…

How to Remove Password Protection from a Directory in cPanel

This guide will explain how to remove password protection from a directory in cPanel. If…

How to Reset Passwords for All WordPress Users

You’ve come to the right place If you want to reset your WordPress users’ passwords.…