In short
A 301 Moved Permanently tells browsers and search engines that an address has permanently moved to a new address. Visitors are redirected automatically, and search engines transfer the new address together with its ranking.
What does status code 301 mean?
The server does not answer the request with the content itself, but with the information that the page can permanently be found at another address. The new address is given in the Location response header. Browsers follow the redirect automatically - your visitors usually do not notice anything.
When should you use a 301 redirect?
- Moving to a new domain
- Switching from
http://tohttps:// - Consistent addresses with or without
www - Changed page addresses, for example after a relaunch or a new menu structure
- Merged pages whose old addresses are still linked
301 or 302? Redirect types at a glance
- 301 Moved Permanently: permanent - search engines adopt the new address.
- 308 Permanent Redirect: permanent like 301, but the request method (e.g. POST) is preserved.
- 302 Found and 307 Temporary Redirect: temporary - the old address stays in the search index, for example during maintenance.
For permanent moves, 301 is the right choice.
Setting up 301 redirects with .htaccess
On our web hosting (Apache) you create redirects in the .htaccess file in the root directory of your website. Many CMS such as WordPress also offer their own plugins or settings for this.
Redirect a single page or folder:
Redirect 301 /old-folder/ https://www.muster.de/new-folder/Redirect all requests to HTTPS:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]Consistently with www:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]Complete domain move - paths are preserved:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^ https://www.muster.de%{REQUEST_URI} [R=301,L]If your .htaccess already contains rules from your CMS (such as the WordPress block), place your redirects above that block.
Unexpected 301 redirect or redirect loop?
- Check the
.htaccessin the root directory and in subfolders for old rules. - Check the address settings of your CMS - in WordPress, for example, "WordPress Address" and "Site Address".
- Browsers remember 301 redirects for a very long time. After making changes, test in a private window or clear the browser cache.
- If the browser reports "too many redirects", two rules redirect to each other - for example an HTTPS rule in the
.htaccessand a second one in the CMS. Remove one of them.
You can see the server's actual response without the browser cache with:
curl -I https://www.muster.de/old-page/Tips for your search engine ranking
- Redirect every old address to the matching new page - not across the board to the home page.
- Avoid redirect chains (A → B → C). Redirect directly to the final destination.
- Update internal links so that they point directly to the new addresses.
- Keep redirects in place permanently after a move.
Related status codes
- 404 Not Found - the page does not exist (anymore)
- 401 Unauthorized - login required
The access logs of your website show how each address is answered: How do I read my log files?