Karachi, Pakistan Mon–Sat: 10AM–7PM PKT
Home Services
Design & Development
UI/UX Design Web Development WordPress Development Responsive Web Design Corporate Website Landing Pages / Microsites E-Commerce Solutions Mobile App Development
Marketing & Growth
SEO Services Content Marketing Social Media Marketing PPC / Google Ads Branding & Creative Speed & Performance
Hosting & Support
Web Hosting Maintenance & Support
Portfolio
Website Design Logo & Graphics
Clients About Blog Free Tools Get a Quote
SEO & Speed Guide

301 vs 302 Redirects: When to Use Each and How to Set Them Up

Every redirect code explained, when to use 301 or 302, working examples for .htaccess, Nginx, PHP and WordPress, and a redirect plan for site migrations.

301 vs 302 redirect: diagram of a 301 permanent redirect from an old URL to a new URL

A 301 redirect tells browsers and search engines that a page has moved permanently, so Google should index the new address and pass its ranking signals there. A 302 redirect means the move is temporary and the old URL should stay in the index. Then use 301 for changed URLs, site migrations, HTTP to HTTPS and www changes; use 302 only for short-term moves. Also, this guide explains every redirect code, shows working examples for Apache, Nginx, PHP and WordPress, and covers the mistakes that cost sites their traffic. In addition, this guide explains 301 vs 302 redirect step by step.

Key takeaways
  • 301 and 308 are permanent; 302 and 307 are temporary. Google treats long-lived 302s as permanent eventually, but do not rely on that.
  • Redirect each old URL to its closest new equivalent, not everything to the home page.
  • Avoid chains (A → B → C) and loops. Each old URL should reach its final page in one hop.
  • Keep migration redirects in place for at least a year, ideally permanently.

301 vs 302 redirect: redirect status codes compared

CodeMeaningMethod kept?Use it for
301Moved permanentlyBrowsers may change POST to GETChanged URLs, migrations, HTTPS and www rules
308Permanent redirectYesPermanent moves for APIs or forms that must keep POST
302Found (temporary)Browsers may change POST to GETShort promotions, A/B tests, maintenance pages
307Temporary redirectYesTemporary moves that must keep the method; also used internally by browsers for HSTS
Meta refresh / JSClient-side redirectNot applicableLast resort when you cannot configure the server

For SEO, Google says 301 and 308 are strong signals that the target should become the canonical URL, while 302 and 307 are weaker. If you see a 307 Internal Redirect in Chrome DevTools on an HTTPS site, that is usually the browser applying HSTS, not your server.

301 vs 302 redirect: when to use a 301

  • You changed a page's slug, for example /services/web to /web-development.
  • Also, you moved to a new domain or merged two websites.
  • You switched from HTTP to HTTPS (see our SSL guide).
  • Also, you standardised on www or non-www.
  • You deleted a product or post that has a close replacement.
  • You merged several thin articles into one stronger guide.

301 vs 302 redirect: when a 302 is the right choice

  • A product is out of stock for a week and you send visitors to a category page.
  • A seasonal page, such as an Eid sale, temporarily replaces the normal offers page.
  • You are sending visitors to a maintenance page during a short update.
  • Geo or language detection that should not replace the original URL in the index.
If a page is gone for good and there is no relevant replacement, a 410 (Gone) or 404 is more honest than redirecting it to the home page. Google treats mass redirects to the home page as soft 404s anyway. See our 404 error guide.

301 vs 302 redirect: how to set up redirects on Apache (.htaccess)

In fact, most shared hosting in Pakistan, including cPanel and Hostinger plans, runs Apache or LiteSpeed, which read .htaccess rules. Always back up the file before editing it, because a typo can cause a 500 error. Also, this matters for 301 vs 302 redirect on every kind of site.

Single page:

Redirect 301 /old-page /new-page

Force HTTPS and www in one hop:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301]

Move a whole folder:

RewriteEngine On
RewriteRule ^blog/2024/(.*)$ /blog/$1 [L,R=301]

Move a whole domain to a new one, keeping paths:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?oldbrand\.pk$ [NC]
RewriteRule ^(.*)$ https://www.newbrand.com/$1 [L,R=301]

Put redirect rules above the WordPress or framework rewrite block, otherwise they may never run.

301 vs 302 redirect: how to set up redirects on Nginx

# Single page
location = /old-page { return 301 /new-page; }

# Force HTTPS and www
server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://www.example.com$request_uri;
}

# Folder move with regex
rewrite ^/blog/2024/(.*)$ /blog/$1 permanent;

Run nginx -t to test the configuration before reloading the server.

301 vs 302 redirect: how to redirect in PHP

<?php
header('Location: https://www.example.com/new-page', true, 301);
exit;

The header() call must run before any HTML is printed, and exit stops the rest of the page from loading.

How to manage redirects in WordPress

  • Redirection plugin (free): add 301s from the dashboard, log 404s and turn the useful ones into redirects.
  • Rank Math or Yoast Premium: include redirect managers and can create a redirect automatically when you change a slug.
  • Large lists: for hundreds of URLs from a migration, server-level rules in .htaccess or Nginx are faster than a plugin, because they run before WordPress loads.

WordPress itself redirects some changed post slugs automatically, but do not depend on it for important pages.

Redirect map for a site migration

Also, when you redesign or move platforms, URL changes are the biggest cause of lost traffic. Plan redirects before launch:

  1. Export every old URL from your sitemap, Search Console (Pages and Performance reports), Google Analytics and a crawler such as Screaming Frog.
  2. Map each one to its closest new URL in a spreadsheet with two columns: old path and new path.
  3. Prioritise pages with backlinks, traffic or conversions. These must map one-to-one.
  4. Implement the rules on the staging site and crawl the old URL list to confirm every one returns a single 301 to a 200 page.
  5. Update internal links to point straight at new URLs, so visitors and crawlers do not depend on redirects.
  6. Submit the new sitemap in Search Console and use the Change of Address tool if the domain changed.
  7. Monitor 404s and indexing for at least eight weeks after launch.

How to test a redirect

Do not trust the browser alone, because browsers cache 301s aggressively. Test from the command line:

curl -I http://example.com/old-page

The response should show HTTP/1.1 301 Moved Permanently and a Location: header with the final URL. Add -L to follow the chain and count the hops. Browser extensions such as Redirect Path, or the Network tab in DevTools with "Preserve log" ticked, also show every step.

Common redirect mistakes

  • Redirect chains: HTTP → HTTPS → www → new slug. Combine them into one rule.
  • Redirect loops: two rules sending traffic back and forth, which shows as "too many redirects" in the browser.
  • Using 302 for permanent moves: common with some plugins and hosting panels. Check the actual status code.
  • Redirecting everything to the home page: loses the relevance of the old pages.
  • Removing redirects too early: old backlinks and bookmarks keep sending visitors for years.
  • Canonical tags and sitemaps still listing old URLs: send mixed signals to Google.

Frequently asked questions

Do 301 redirects lose SEO value?

Google has confirmed that 301, 302 and other server-side redirects no longer lose PageRank. The bigger risk is redirecting to an unrelated page, which Google may ignore.

How long should I keep a 301 redirect?

Google recommends at least one year. In practice, keep important redirects permanently, since they cost almost nothing.

Can I change a 302 to a 301 later?

Yes. Change the rule on the server; Google will pick up the permanent signal on its next crawl.

Why does my browser still show the old redirect after I removed it?

Browsers cache 301 responses. Test in a private window or with curl, and clear the browser cache.

Related guides: ERR_TOO_MANY_REDIRECTS, Why Website Speed Matters and How to Make Your Site Faster and How to Get Your Website on Google.

For official guidance, see Google Search Central.

Planning a redesign or migration?

We build full redirect maps and test them before launch, so you keep your rankings when you move. See our web development and SEO services, or contact us for a migration plan.

Written by the ItsWebExpert team, a web design and development company in Karachi building websites, online stores and apps for businesses across Pakistan.

Ask a Question on WhatsApp

Let's Build Your
Next Website

Tell us what you need and we will reply within 24 hours with honest advice and a fixed quote.

Trusted by our clients, rated 5.0 on Google

5.0 11 Google reviews Read all →
I had a great experience working with Waqas and his team. We got some website development and SEO work done, and I'm quite satisfied with the overall results. They understood our requirements, suggested improvements, and handled the work professionally. What I appreciated most was their communication, attention to detail, and willingness to make changes whenever needed. Waqas is very cooperative, and the team knows what they're doing. Definitely a good choice for anyone looking for reliable web development and digital marketing services.
HUHafiz Ubaid Google review · Nov 2026
I was referred to their company by someone, and I'm really glad I connected with them. Waqas, the CEO, is a very humble and professional person who leads his team exceptionally well. Their expertise in digital marketing, web development, and custom development services is impressive. The team is skilled, responsive, and committed to delivering quality work. Had a really positive experience working with them. Highly recommended!
MRMuhammad Rafeeq Google review · Nov 2026
I had hired them for my client's task of Custom Wordpress plugin development. and many other tasks later on.. Waqas is super fast and sharp.. I know him since 2019.. I really really appreciate his work. Highly recommended..
RFRaheela Farooqui Google review · Nov 2026
I had a positive experience working with Waqas and his team. They provided excellent support with graphic design and social media management. The team was professional, responsive, and attentive to our needs. They understood our vision and delivered quality work on time. Highly recommended for anyone looking for creative and reliable digital services.
URUsman Rock Google review · Nov 2026
I really appreciate their dedication and professionalism. They have a good understanding of SEO, social media marketing, and online brand growth. Communication is smooth, and the quality of work is impressive. Definitely a great team to work with!
SSSameer Sarafaraz Google review · Nov 2026
I've had a great experience working with their team. They understand digital marketing very well and know how to improve online visibility through effective SEO and marketing strategies. Professional, responsive, and reliable. Highly recommended! 🙌❤️
MNMohammad naveed Google review · Nov 2026
I had a really good experience with web Experts. Everything was easy to understand, well-organized, and user-friendly. I appreciate the effort and attention to detail that has gone into creating this platform. It was a smooth and pleasant experience, and I would definitely recommend it to others. Keep up the great work!
SSShazia shaikh Google review · Nov 2026
Extremely professional and committed I am Extremely happy to work with them I wish them best of luck Best Regards M. Salman Farooqui
SFSalman Farooqui Google review · Nov 2026
Outstanding experience! Quality, professionalism, and customer service are all excellent. Keep up the great work!
ARabdul rehman Google review · Nov 2026
Excellent service and a great experience. The team is professional, helpful, and dedicated. Highly recommended!
MEmustafa emb Google review · Nov 2026