Understand 301 redirects
Reviewed
Markdown ↓➡️
Moved Permanently.
The 301 HTTP status code means "Moved Permanently". It is not an error — the requested URL has a new permanent home and clients should use it from now on.
A 301 is a redirect, not an error. The server answers a request by pointing the client to a different URL. Browsers, crawlers, and API clients follow that new location automatically.
When 301 redirects happen
- Forcing
https://instead ofhttp:// - Routing a test domain to the primary custom domain
- Moving content to a new path after a relaunch
- Normalizing the
www.and the bare domain to a single host
Browser caching
This is the one thing to know about 301: browsers cache it hard, often permanently. Once a browser has seen a 301 for an URL, it may stop asking the server about the original address at all and jump straight to the target.
That makes a 301 hard to take back. A wrong rule can stick in visitors' browsers for a long time, and there is no way to clear it remotely. Test redirect rules with curl -I or a private browser window before making them permanent.
$ curl -I https://example.frb.io
HTTP/2 301
location: https://www.your-domain.example/
When in doubt whether a redirect should be permanent, start with a 302 and switch to 301 once the new URL is confirmed stable.
SEO considerations
Search engines read a 301 as the signal to move a page's ranking to the new URL. For a permanent move this is the correct code: it consolidates link equity onto the target and updates the index over time.
- Use 301, not 302, when content moves for good, so the ranking follows.
- Redirect to the final URL in a single hop — avoid redirect chains.
- Set a canonical URL as well, so search engines know which address is the single source.
Domain redirects on fortrabbit
Domain redirects configured in the dashboard use a 301. When a domain is set to forward to another domain, requests are answered with a permanent 301 to the target. See domain forwarding.
Set up a 301
Most custom 301 redirects on fortrabbit are written in .htaccess with mod_rewrite. See Redirects with .htaccess for force-https and domain redirect examples.