Understand 301 redirects
Published
Updated
➡️
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 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
- fortrabbit redirects every
http://request tohttps:// - A domain set to forward in the dashboard, see domain forwarding
- A
.htaccessrule that sends the default domain to the primary domain - A page moved to a new path after a relaunch
Browser caching
Browsers cache a 301. Once a browser has seen a 301 for a URL, it may stop asking the server about the original address 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://en-34fdsa.eu-w1a.frbit.app
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 right code.
- Use 301, not 302, when content moves for good, so the ranking follows.
- Redirect to the final URL in a single hop, without redirect chains.
- Set a canonical URL as well, so search engines know which address is the single source.
Set up a 301
Custom 301 redirects on fortrabbit go into .htaccess. See redirects with .htaccess.