Skip to content
BeoHosting
BeoHosting
Technical

How to Set Up a 301 Redirect - A Guide

BeoHosting Team··7 min read read
How to Set Up a 301 Redirect - A Guide

A 301 redirect is one of the most important tools for managing URLs on your site. Whether you are changing site structure, moving to a new domain, or deleting old pages, a proper 301 redirect ensures you do not lose SEO value and that visitors always reach the right content. In this guide we explain everything you need to know.

What is a 301 redirect?

HTTP status code 301 means "Permanently Moved". When a browser or Google bot accesses a URL with a 301 redirect, the server tells them the content has permanently moved to a new location and automatically redirects them to the new URL.

The key word is "permanently" - unlike a 302 redirect (temporary), a 301 redirect signals to search engines to transfer all SEO value (link juice, PageRank) from the old URL to the new one. This is critical for preserving your Google rankings.

When to use a 301 redirect

Domain change: Moving from olddomain.com to newdomain.com. Every page on the old domain should redirect to the corresponding page on the new domain.

URL structure change: You are changing URL format, for example from yoursite.com/blog?id=123 to yoursite.com/blog/article-title. All old URLs should redirect to the new ones.

Deleting pages: If you delete a page that has backlinks or traffic, redirect it to the most relevant existing page instead of returning a 404.

Consolidating duplicate content: If you have the same content at multiple URLs, redirect all variants to the canonical (main) version.

HTTPS migration: Moving from HTTP to HTTPS requires 301 redirects from all HTTP URLs to the HTTPS versions.

WWW / non-WWW: Choose whether you use www.yoursite.com or yoursite.com and redirect the other variant to the chosen one.

How to set up a 301 redirect in .htaccess

The .htaccess file is a configuration file for Apache and LiteSpeed servers, located in the root directory of your site. This is the most common and most flexible way to set up redirects.

Single URL redirect: Add the line: Redirect 301 /old-page https://yoursite.com/new-page. This will redirect every request for /old-page to the new location.

Whole domain redirect: To redirect from old domain to new, use RewriteEngine On, RewriteCond %{HTTP_HOST} ^olddomain\.com$ and RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]. This redirects every page from the old domain to the same path on the new domain.

HTTP to HTTPS: RewriteEngine On, RewriteCond %{HTTPS} off, RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]. This redirects every HTTP request to its HTTPS version.

Non-WWW to WWW (or vice versa): RewriteEngine On, RewriteCond %{HTTP_HOST} ^yoursite\.com$ and RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R=301,L]. For the reverse direction, swap the conditions.

Important: .htaccess is processed top-down - the order of rules matters. Put more specific rules before general ones.

301 redirects in WordPress

WordPress users have several options to set up redirects without manually editing .htaccess:

Redirection plugin: The most popular free plugin for managing redirects. It has a simple interface where you enter the old URL and the new URL, and the plugin automatically creates the 301 redirect. It also tracks 404 errors so you can see which non-existent pages visitors are trying to open.

Yoast SEO Premium: If you already use Yoast SEO Premium, you have a built-in redirect manager. Yoast even automatically suggests a redirect when you change the slug (URL) of a post or page.

Rank Math: A free SEO plugin with a built-in redirect module. Similar to the Redirection plugin but integrated into an SEO tool you probably already use.

The advantage of plugins over manual .htaccess editing is simplicity and the ability to manage redirects from the WordPress admin panel without technical knowledge.

301 redirects in cPanel

cPanel offers a graphical interface for setting up redirects without writing code. Steps:

1. Log in to the hosting control panel and find the "Domains" section.

2. Click "Redirects".

3. Choose type: "Permanent (301)" for a permanent redirect.

4. Select the domain from the dropdown.

5. Enter the old path (e.g. /old-page) and the new full URL (e.g. https://yoursite.com/new-page).

6. Choose whether the redirect applies to the www or non-www version.

7. Click "Add" to activate the redirect.

cPanel modifies the .htaccess file under the hood, so the result is the same as manual editing but without risk of syntax errors.

Common 301 redirect mistakes

Redirect loops: The most common mistake is when page A redirects to page B and page B redirects back to A. The browser shows "ERR_TOO_MANY_REDIRECTS". Always make sure the target page does not redirect back to the source.

Redirect chains: Page A redirects to B, B redirects to C, C redirects to D. Each step adds latency and Google may stop following the chain after 5 hops. Always redirect directly to the final destination.

Redirecting to a 404 page: If the new page you redirect to does not exist, the user will get a 404 after the redirect. Always verify the target page exists before setting the redirect.

Forgetting the trailing slash: /page and /page/ can be different URLs. Be consistent and set a redirect from one variant to the other.

Using 302 instead of 301: A 302 redirect does not pass SEO value. If the move is permanent, always use 301.

How to test a 301 redirect

After setting up the redirect, always test it. The simplest way is to open the old URL in a browser and check that it forwards to the new URL. However, browsers cache redirects, so for precise testing use:

Online tools like httpstatus.io or redirect-checker.org that show HTTP status codes and the redirect chain. You can also use Chrome DevTools (F12 > Network tab), where you will see the 301 status and the Location header with the new URL.

For bulk testing of many redirects, use Screaming Frog SEO Spider, which can check hundreds of URLs at once and report all redirect issues.

Conclusion

The 301 redirect is an essential tool for anyone managing a website. Proper implementation protects your SEO value, provides a good user experience, and prevents traffic loss when you change things on the site. Whether you use .htaccess, a WordPress plugin, or cPanel, the key is careful planning, testing, and avoiding common mistakes. If you are unsure, BeoHosting technical support is here to help you set up redirects on your hosting.

BeoHosting Team

10+ years of experience — Web hosting and infrastructure specialists

  • Web Hosting
  • WordPress Hosting
  • VPS
  • Dedicated Serveri
  • Domeni
  • SSL
  • cPanel
  • LiteSpeed
  • Linux administracija
  • DNS

Last updated: