In this article · 9 sections
- Quick definitions
- When to use a 301 redirect
- When a 404 is the right answer
- Mistakes to avoid
- Setting up redirects on a PHP / Apache website
- A custom 404 page that helps
- Finding broken links and lost pages
- Frequently Asked Questions
- How long should I keep a 301 redirect?
- Do 404 errors in Search Console hurt my rankings?
- Should I use 410 instead of 404?
- Can redirects slow down my site?
- Changing URLs or redesigning?
Websites change. Services are discontinued, pages are renamed, blog posts are merged, and old .php URLs become clean URLs. Each time a URL changes, you have a choice: send visitors somewhere useful with a redirect, or tell them and Google that the page no longer exists with a 404. Both are correct in the right situation. Problems start when they're used in the wrong one.
Quick definitions
| Status code | Meaning | Typical use |
|---|---|---|
| 301 | Moved permanently | Page has a new URL forever |
| 302 / 307 | Moved temporarily | Short-term changes, A/B tests, maintenance |
| 404 | Not found | Page doesn't exist and has no replacement |
| 410 | Gone | Page was deliberately removed for good |
When to use a 301 redirect
- You changed a page's URL (for example
/web-design.php→/website-design-ludhiana). - You merged two similar articles into one stronger article.
- You moved from http to https or from www to non-www.
- You changed domain name.
- A discontinued service has a close replacement (for example an old package page → the current packages page).
A 301 passes visitors — and most of the old page's ranking signals — to the new URL.
When a 404 is the right answer
- The page has no relevant replacement.
- Someone typed a wrong URL.
- Spam bots request random URLs like
/wp-login.phpon a non-WordPress site.
404s are a normal part of the web and don't hurt your rankings by themselves. Google has said so many times. What hurts is losing valuable links and visitors that pointed to an important page.
Mistakes to avoid
- Redirecting everything to the homepage. Google often treats this as a "soft 404", and visitors are confused. Redirect to the most relevant page, or let it 404.
- Redirect chains: A → B → C → D. Point every old URL directly to the final destination.
- Redirect loops that send browsers in circles and show an error.
- "Soft 404s": a page that says "Not found" but returns status 200. Make sure your 404 page actually sends a 404 code.
- Leaving internal links to old URLs. Update menus, footers and blog links to the new URL directly instead of relying on redirects.
Setting up redirects on a PHP / Apache website
On most shared hosting (including Hostinger), redirects go in the .htaccess file in your website's root folder. A single page:
Redirect 301 /old-page.php https://example.com/new-page
A pattern using mod_rewrite, for example removing .php from URLs that visitors request directly:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/([^.\s?]+)\.php[\s?] [NC]
RewriteRule ^ https://%{HTTP_HOST}/%1 [R=301,L]
The THE_REQUEST condition prevents a loop when the clean URL is internally mapped back to the PHP file. Always test redirects after uploading — a mistake in .htaccess can take the whole site down, so keep a backup of the previous version.
In PHP itself, you can redirect with:
header('Location: https://example.com/new-page', true, 301);
exit;
A custom 404 page that helps
Your 404 page should keep visitors on the site: a friendly message, a search box, links to main services, contact details and WhatsApp. It should also include noindex so it never appears in search results.
Finding broken links and lost pages
- Search Console → Indexing → Pages → Not found (404): URLs Google tried that don't exist.
- Search Console → Links: see which external sites link to which pages; make sure those pages still work.
- A crawler such as Screaming Frog (free up to 500 URLs) to find broken internal links.
Prioritise fixing 404s that have external links or used to get traffic. Ignore random junk URLs.
Frequently Asked Questions
How long should I keep a 301 redirect?
Ideally permanently. At minimum a year, but old links on other sites can keep sending visitors for many years.
Do 404 errors in Search Console hurt my rankings?
Not by themselves. They only matter if important pages or valuable links are broken.
Should I use 410 instead of 404?
Either works. 410 may lead Google to drop the URL slightly faster, but the difference is small.
Can redirects slow down my site?
A single redirect adds very little time. Long chains add up, so keep redirects direct.
Changing URLs or redesigning?
Follow our migration checklist, see web development services, or contact Joboo Web to map redirects for you.