In this article
301 or 302?
| Code | Means | Use for |
|---|---|---|
| 301 | Moved permanently | Renamed pages, new domains, HTTPS, merged content |
| 302 | Found / temporary | Short-term changes, such as a page under maintenance |
A 301 tells search engines to transfer the old page’s signals to the new address. Browsers also remember 301s, so test carefully before going live.
Common jobs
- Force HTTPS: every http:// request goes to https://.
- Choose www or non-www: pick one version so links and rankings are not split.
- Move a whole site: old-domain.com/any-page → new-domain.com/any-page.
- Single pages: /old-services/ → /services/web-design/.
How to generate the rules
- Open the .htaccess Redirect Generator.
- Tick site-wide rules: force HTTPS, add or remove www, or enter a new domain.
- Add any number of single-page redirects (old path → new address) as 301 or 302.
- Read the warnings – for example, choosing both “add www” and “remove www” would create a loop.
- Copy or download the code.
Editing .htaccess safely
- Download a backup of your current .htaccess file (via your host’s file manager or FTP). It is hidden by default – enable “show hidden files”.
- On WordPress, paste your rules above the
# BEGIN WordPressblock, never inside it – WordPress rewrites that block. - Save, then test old addresses in a private browser window.
- If the site shows an error 500, restore the backup immediately and check the rules for typos.
Avoid chains and loops
A chain is A → B → C. Each hop slows visitors down, and search engines may stop following after several. When you move a page again, update old redirects to point straight to the final address. A loop (A → B → A) makes the page unreachable; browsers show “too many redirects”.
Moving to a new domain: checklist
- Redirect every old URL to its equivalent – not everything to the new home page.
- Update internal links, canonical tags and your sitemap.
- Use Google Search Console’s Change of Address tool.
- Keep the redirects in place for at least a year – ideally permanently.
Not using Apache?
.htaccess works on Apache and LiteSpeed servers, used by most shared hosting. Nginx ignores it – ask your host for equivalent server rules, or use a redirect plugin in WordPress. Cloudflare and some hosts also offer redirect rules in their dashboards.
Find pages that need redirects
Google Search Console’s Pages report lists “Not found (404)” URLs that Google has seen. Map each to its best new page. Check your URLs with the URL Parser, and update your sitemap with the XML Sitemap Generator afterwards.