How to Set Up Redirects (301 vs 302)

What are HTTP redirects
An HTTP redirect is a mechanism that automatically forwards visitors (and search engines) from one URL to another. When a browser requests a page that has a redirect, the server responds with a status code that tells the browser the content has moved to a new address. The browser then automatically goes to the new URL without the user needing to do anything.
Redirects are everywhere on the internet. Every time a site moves from HTTP to HTTPS (with SSL enabled on the domain), changes URL structure, deletes a page, or changes domain - redirects are used. Properly configured redirects preserve user experience and SEO value, while wrong ones can destroy your site's rankings.
301 redirect (permanent)
When to use 301
A 301 redirect tells search engines and users that the page is permanently moved to a new address. This is the most common type of redirect and the one you should use in most cases:
- URL structure change: When you change a page slug (e.g. /old-url to /new-url).
- Move to HTTPS: Redirect of all HTTP pages to HTTPS versions.
- Domain change: When you change the site domain (old-site.com to new-site.com).
- Deleting a page: Redirecting a deleted page to the most relevant alternative.
- www vs non-www: Choosing one version and redirecting the other.
SEO effect of 301 redirects
A 301 redirect transfers most SEO value (link juice) from the old URL to the new. Google has confirmed that 301 redirects do not lose PageRank, which means the new URL inherits the ranking of the old. This is critical when changing URLs of pages that already have good rankings and backlinks.
Google processes 301 redirects by removing the old URL from the index and replacing it with the new one. This process can take from a few days to a few weeks, depending on how often Google visits your site.
302 redirect (temporary)
When to use 302
A 302 redirect tells search engines that the page is temporarily moved and that the original URL will return. Use 302 in the following situations:
- A/B testing: Temporarily redirecting part of traffic to a test page.
- Maintenance: Temporary redirect to a maintenance page while working on the site.
- Geo-redirect: Forwarding users to a localized version of the site based on location.
- Seasonal content: Temporary redirect to a current campaign or offer.
SEO effect of 302 redirects
A 302 redirect does not transfer SEO value to the new URL because Google expects the original URL to return. The old URL stays in the index and keeps its ranking. If you mistakenly use 302 instead of 301, Google may keep the old URL in the index for a long time instead of replacing it with the new one, meaning you will have two URLs for the same content.
How to set up redirects in .htaccess
Single redirect
The simplest way to add a redirect on an Apache server is through the .htaccess file. On BeoHosting you do this via the cPanel control panel. Add the following lines to the top of the .htaccess file:
Redirect 301 /old-page /new-page
For 302: Redirect 302 /temporary-page /replacement
Redirect with RewriteRule
For more advanced redirects use mod_rewrite. For example, redirecting all pages from HTTP to HTTPS:
RewriteEngine OnRewriteCond %{'{'}HTTPS{'}'} offRedirect 301 / https://yoursite.com/
To redirect from www to non-www version:
RewriteEngine OnRewriteCond %{'{'}HTTP_HOST{'}'} ^www\\.yoursite\\.com$ [NC]RewriteRule ^(.*)$ https://yoursite.com/$1 [R=301,L]
Redirect of a whole domain
If you change domain and want all traffic to go to the new one:
RewriteEngine OnRewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]
Redirects in WordPress
Redirect plugins
If you are not a technical person, WordPress plugins are the easiest way to manage redirects:
- Redirection: The most popular free plugin with over 2 million installs. Automatically tracks 404 errors and offers redirect creation.
- Yoast SEO Premium: Has a built-in redirect manager that automatically suggests a redirect when you change a page slug.
- Rank Math: A free SEO plugin with a redirects module and 404 tracking.
- Safe Redirect Manager: A lightweight plugin that stores redirects in the database instead of .htaccess.
WordPress automatic redirects
WordPress has a built-in system that automatically redirects old slugs to new ones when you change the permalink of a page or post. However, this does not always work reliably, especially for large URL structure changes. That is why it is recommended to use a redirect plugin as an additional safety layer.
Most common redirect mistakes
- Redirect chains: A redirects to B, B to C, C to D. Every step slows loading and loses SEO value. Always redirect directly to the final destination.
- Redirect loops: A redirects to B, B redirects to A. The browser shows the "ERR_TOO_MANY_REDIRECTS" error. Always check that redirects do not form a circle.
- 302 instead of 301: Using 302 instead of 301 for a permanent change. This blocks SEO value transfer.
- Redirect to 404: Redirecting to a page that does not exist. Always check that the destination works.
- Too many redirects: Hundreds of redirects in .htaccess slow the server. Clean up old redirects that are no longer needed.
Conclusion
Redirects are a key tool for preserving SEO value and user experience during site changes. Use 301 for permanent changes and 302 for temporary ones. Avoid redirect chains, loops, and wrong types. Regularly check for 404 errors and create redirects for pages that users and Google try to visit. Proper redirect management can be the difference between preserved and lost rankings. See also our redirects in cPanel guide.
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: