Nov 23, 2017 10:00:15 AM |
301 Moved Permanently: What It Is and How to Fix It
A close look at what a 301 Moved Permanently response code is, including troubleshooting tips to help you resolve this error in your own application.
A 301 Moved Permanently is an HTTP response status code
indicating that the requested resource has been permanently moved to a new URL provided by the Location
response header. The 3xx
category of response codes are used to indicate redirection messages to the client, such that the client will become aware that a redirection to a different resource or URL should take place.
It can be a challenge to differentiate between all the possible HTTP response codes and determine the exact cause of a message like the 301 Moved Permanently
code. There are dozens of possible HTTP status codes used to represent the complex relationship between the client, a web application, a web server, and often multiple third-party web services, so determining the cause of a particular status code can be difficult. In this article we’ll examine the 301 Moved Permanently
code by looking at a few troubleshooting tips, along with some potential fixes for common problems that might be causing this issue, so let’s get started!
The Problem is Server-Side
All HTTP response status codes that are in the 3xx
category are considered redirection messages
. Such codes indicate to the user agent (i.e. your web browser) that an additional action is required in order to complete the request and access the desired resource. Unlike gateway related 5xx
response codes, like the 502 Bad Gateway Error
we’ve looked at recently, which may indicate issues either on an upstream server or the client, the 301 Moved Permanently
code generally indicates an issue on the actual web server hosting your application.
That said, the appearance of a 301 Moved Permanently
is usually not something that requires much user intervention. Most browsers should automatically detect the 301 Moved Permanently
response code and process the redirection action automatically. The web server hosting the application should typically include a special Location
header as part of the response it sends to the client. This Location
header indicates the new URL where the requested resource can be found. For example, if a request comes in to access the URL https://airbrake.io
, but the web server is configured to forces redirection to a secure version using https
, the server response will include the Location: https://airbrake.io
header. This tells the browser that it should redirect this request (as well as all future ones) to https://airbrake.io
to the secured URL of https://airbrake.io
. In most cases, the browser will automatically detect this 301 Moved Permanently
response code, read the new Location
URL, and redirect the request to that new location. It is considered best practice to use a 301 Moved Permanently
redirection to transition a user agent from HTTP to the secure HTTPS. Thus, if you attempt to go to the insecure URL of https://airbrake.io right now, you’ll automatically be redirected to the HTTPS version of the site (https://airbrake.io).
Since the 301 Moved Permanently
indicates that something has gone wrong within the server
of your application, we can largely disregard the client
side of things. If you’re trying to diagnose an issue with your own application, you can immediately ignore most client-side code and components, such as HTML, cascading style sheets (CSS), client-side JavaScript, and so forth. This doesn’t apply solely to web sites, either. Many smart phone apps that have a modern looking user interface are actually powered by a normal web application behind the scenes; one that is simply hidden from the user. If you’re using such an application and a 301 Moved Permanently
occurs, the issue isn’t going to be related to the app installed on your phone or local testing device. Instead, it will be something on the server-side, which is performing most of the logic and processing behind the scenes, outside the purview of the local interface presented to the user.
All of that said, if your application is generating 301 Moved Permanently
codes improperly or unexpectedly, there are a number of steps you can take to diagnose the problem.
Start With a Thorough Application Backup
As with anything, it’s better to have played it safe at the start than to screw something up and come to regret it later on down the road. As such, it is critical that you perform a full backup of your application, database, and so forth, before attempting any fixes or changes to the system. Even better, if you have the capability, create a complete copy of the application onto a secondary staging
server that isn’t «live,» or isn’t otherwise active and available to the public. This will give you a clean testing ground with which to test all potential fixes to resolve the issue, without threatening the security or sanctity of your live application.
Diagnosing a 301 Moved Permanently Response Code
A 301 Moved Permanently
response code indicates that the server believes that the requested resource is invalid and that the request should be redirected to a new, «proper» URL. I use the word believes
here because it’s entirely possible that the server is misconfigured or bugged in some way, which is causing it to provide 301 Moved Permanently
codes for resources/URLs that are totally valid. Thus, a large part of diagnosing the issue will be going through the process of double-checking what resources/URLs are generating 301 Moved Permanently
response codes and determining if these codes are appropriate or not.
That said, if your application is responding with 301 Moved Permanently
codes that it should not be issuing, this is an issue that many other visitors may be experiencing as well, dramatically hindering your application’s ability to service users. We’ll go over some troubleshooting tips and tricks to help you try to resolve this issue. If nothing here works, don’t forget that Google is your friend. Don’t be afraid to search for specific terms related to your issue, such as the name of your application’s CMS or web server software, along with 301 Moved Permanently
. Chances are you’ll find others who have experienced this issue and have come across a solution.
Troubleshooting on the Server-Side
Here are some additional tips to help you troubleshoot what might be causing the 301 Moved Permanently
to appear on the server-side of things:
Check the Server Configuration Files
— Your application is likely running on a server that is using one of the two most popular web server softwares,Apache
ornginx
. At the time of publication, both of these web servers make upover 84%
of the world’s web server software! Thus, one of the first steps you can take to determine what might be causing these301 Moved Permanently
response codes is to check the configuration files for your web server software for unintentional redirect instructions.
To determine which web server your application is using you’ll want to look for a key file. If your web server is Apache then look for an .htaccess
file within the root directory of your website file system. For example, if your application is on a shared host you’ll likely have a username associated with the account on that host. In such a case, the application root directory is likely something like /home/<username>/public_html/
, so the .htaccess
file would be at /home/<username>/public_html/.htaccess
.
If you located the .htaccess
file then open it in a text editor and look for lines that use RewriteXXX
directives, which are part of the mod_rewrite
module in Apache. Covering exactly how these rules work is well beyond the scope of this article, however, the basic concept is that a RewriteCond
directive defines a text-based pattern that will be matched against entered URLs. If a matching URL is requested by a visitor to the site, the RewriteRule
directive that follows one or more RewriteCond
directives is used to perform the actual redirection of the request to the appropriate URL. Therefore, if you find any strange RewriteCond
or RewriteRule
directives in the .htaccess
file that don’t seem to belong, try temporarily commenting them out (using the #
character prefix) and restarting your web server to see if this resolves the issue.
On the other hand, if your server is running on nginx
, you’ll need to look for a completely different configuration file. By default this file is named nginx.conf
and is located in one of a few common directories: /usr/local/nginx/conf
, /etc/nginx
, or /usr/local/etc/nginx
. Once located, open nginx.conf
in a text editor and look for the return
or rewrite
directives. For example, here is a simple block directive
(i.e. a named set of directives) that configures a virtual server by creating a redirection from invalid-domain.com
to the proper valid-domain.com
URL:
server {
listen 80;
listen 443 ssl;
server_name invalid-domain.com;
return 301 $scheme://valid-domain.com$request_uri;
}
Rewrite
directives in nginx
are similar to the RewriteCond
and RewriteRule
directives found in Apache
, as they tend to contain more complex text-based patterns for searching. Either way, look through your nginx.conf
file for any abnormal return
or rewrite
directives and comment them out before restarting the server to see if the issue was resolved.
Check the Logs
— Nearly every web application will keep some form of server-side logs.Application logs
are typically the history of what the application did, such as which pages were requested, which servers it connected to, which database results it provides, and so forth.Server logs
are related to the actual hardware that is running the application, and will often provide details about the health and status of all connected services, or even just the server itself. Google «logs [PLATFORM_NAME]» if you’re using a CMS, or «logs [PROGRAMMING_LANGUAGE]» and «logs [OPERATING_SYSTEM]» if you’re running a custom application, to get more information on finding the logs in question.Application Code or Script Bugs
— If all else fails, it may be that a problem in some custom code within your application is causing the issue. Try to diagnose where the issue may be coming from through manually debugging your application, along with parsing through application and server logs. Ideally, make a copy of the entire application to a local development machine and perform a step-by-step debug process, which will allow you to recreate the exact scenario in which the301 Moved Permanently
occurred and view the application code at the moment something goes wrong.
No matter what the cause, the appearance of a 301 Moved Permanently
within your own web application is a strong indication that you may need an error management tool to help you automatically detect such errors in the future. The best of these tools can even alert you and your team immediately when an error occurs. Airbrake’s error monitoring software provides real-time error monitoring and automatic exception reporting for all your development projects. Airbrake’s state of the art web dashboard ensures you receive round-the-clock status updates on your application’s health and error rates. No matter what you’re working on, Airbrake easily integrates with all the most popular languages and frameworks. Plus, Airbrake makes it easy to customize exception parameters, while giving you complete control of the active error filter system, so you only gather the errors that matter most.
Check out Airbrake’s error monitoring software today and see for yourself why so many of the world’s best engineering teams use Airbrake to revolutionize their exception handling practices!
If you own a website and receive a 301 Moved Permanently error in your web browser, the website’s server directs you to a new URL, which doesn’t immediately seems to need a fix. That is most likely due to the website’s change of address or domain name. The error is an HTTP status code that tells hat the website you’re trying to access has been permanently moved to a new URL. If you see this error frequently, it’s time to make some moves and learn to fix it.
What Does HTTP Status 301 Moved Permanently Mean?
The 301 Moved Permanently error is an HTTP status code that tells you that the website you’re trying to access has been permanently moved to a new URL. The most common cause of the error is the website changing the address or domain name. When a website changes its address, all its pages should be redirected to the new URL. However, sometimes these redirects don’t work correctly, and you see a 301 error code.
Here is a video by Google Search Central that explains 301 redirects and how Google treats them –
Other Names for the 301 Moved Permanenty Error
The Error 301 Moved error is related to a website or webpage that has been moved to a different URL. The HTTP response status code also indicates that the requested resource has been permanently moved to another location. Therefore, the 301 error is often known as “HTTP 301” or “301 permanent redirect error”.
When you encounter this error, it is typically accompanied by a message like “The page has been moved permanently.” This error usually occurs when someone tries to access a page that has been removed or relocated. There are a few things that you can do if you encounter this error. You can try basic methods to see if it’s fixed such as refreshing the page. You can attempt to access the page from a different browser if that doesn’t work. If you cannot get it done, go over the other procedures one by one. With that said, there are a dozen ways to fix the 301 Moved Permanently error.
What causes the 301 Error?
There are many reasons why a webpage will display the 301 error. Some of them are given below –
- When a website’s URL structure is changed, and the webmaster has set a redirect on the old URLs to the new ones.
- A website is entirely migrated from one domain to another. Hence, the old domain is redirected to the new domain.
- Due to a misconfiguration or an improper configuration of the server redirects occurs.
Backup your Website (Precaution)
It’s always better to go safe at the start rather than regret it later on. As a result, you must do a complete backup of your web application, database, and other resources before attempting any repairs or modifications to the system. It’s also preferable if you can make a complete duplicate of the application onto a second staging server that isn’t “live,” i.e., isn’t currently active and accessible to the public. This will offer you a clean testing environment to test all potential fixes for the problem without jeopardizing your live application’s security or privacy.
Methods to Fix 301 Error
In order to fix this error, there are some methods you can try. Based on the reason why the error has happened, you will be able to solve the issue.
1. Check for .htaccess File Redirects
If you’re using a .htaccess file to redirect visitors from your old website’s pages to your new ones, check the file for any errors. If there are any typos or incorrect entries in the file, it could be causing the 301 Moved Permanently error. You can use a free online .htaccess checker tool to check your file for potential errors.
More About the .htaccess File
A server configuration file known as .htacess stands for “hypertext access”. Each file contains configuration instructions for a server in a directory. In other words, each htaccess file provides instructions to a server, such as passcode requirements for specific parts of a website and configuration settings for automatic redirects on particular website sections. If you want to modify it, remember that it must be called .htaccess only. To find the .htaccess file in Apache, log into your account on the server hosting and select your username. Locate and modify the lines that mention rewrite directives in the file to ensure that any redirects within your website have corresponding URL links.
Rewrite engine directives can be changed in two ways: one way is to use RewriteCond, whereas the other option is to use RewriteRule. If running on Nginx, your rewrite instructions are identified as a return or rewrite directive rather than RewriteCond and RewriteRule. You’ll want to double-check both in your .htaccess file to ensure that there aren’t any that no longer exist. If you find them, remove them temporarily and restart your website server to see if the problem goes away.
2. Check Your Server Logs
The next step is to check your web server’s error logs. This will give you more information about why the 301 Moved Permanently error is generated. There are plenty of WordPress-related logs to check, and if you lack access or knowledge, you can ask your hosting provider for help.
3. Use a Third-party Tool for Checking 301 Redirects
If you want to check whether your website’s 301 redirects are working correctly, then you can use a free online tool like the SEOmoz Redirect Checker. This tool will show you the HTTP status code for each page on your website and any redirects in place.
4. Check for Syntax Errors
If you’re still seeing the “HTTP Error 301 Moved Permanently” error, some syntax errors in your .htaccess file may exist. Again, you may employ a free syntax checker tool online for these. This tool will scan your .htaccess file and highlight any potential errors. Once you’ve found and fixed the errors, restart your web server and try accessing your website again. You can contact your hosting provider for help if you’re still having trouble. They’ll be able to check your server logs and .htaccess file for any potential problems.
5. Examine Your Sitemap
If you have a sitemap, check to see if it contains any broken links. A broken link is a link that points to a page that no longer exists. You’ll need to update your site map if you find any broken links. You can use a free online tool like the Xenu Link Sleuth to check for broken links on your website.
6. Check for Plugin Conflicts
If you’re using WordPress, a plugin conflict might be causing the 301 Moved Permanently error. To check for this, deactivate all your plugins and try accessing your website again. If the difficulty goes away, a plugin likely caused it. You can then start reactivating your plugins one at a time until you find the one that’s causing the concern. Once you find the problematic plugin, you can try contacting the plugin developer for help or seek an alternative
7. Clear Your Browser’s Cache
If you’re still getting the error, there might be an issue with your browser’s cache. To clear your cache, go to your browser’s settings and look for the option to clear your history or cookies. Use our guide on clearing Chrome cache on Windows as a reference.
8. Look for Custom Code Files
If you have added custom code on your website with issues, it may cause redirect problems. To check this, remove the custom code line or lines, especially if you added them recently. Refresh the page to see if the error message disappears to determine if this was the source of the issue.
9. Remove Redirect Loops (If Any)
A redirect loop is when a page keeps redirecting you to itself or another that redirects back to the original page. This can happen if there’s a mistake in your .htaccess file or if you’ve accidentally created a redirect loop. To fix this, you’ll need to find and remove the redirect loop. You utilize the aforementioned SEOmoz Redirect Checker tool to check for redirect loops on your website.
10. Reset Your Permalink Structure
If the error still troubles you, there might be an issue with your WordPress permalinks. Go to your WordPress dashboard and navigate to Settings → Permalinks. Choose any other structure, click Save Changes, then switch back to the original before clicking Save Changes again.
11. Contact Your Hosting Provider
If you’ve tried all of the above and still see the 301 Moved Permanently error, you’ll need to contact your hosting provider for assistance. We already mentioned they can check logs, but these experts can also troubleshoot and solve issues.
FAQs
How does a 301 redirect work?
If you are wondering how 301 redirects work, here it is – A 301 redirect works by sending a response to the web browser or search engines by telling them that the requested resource has been permanently moved to a new URL. The response will contain a new URL where the browser should take the visitors.
Can I undo a 301 redirect?
You can, technically, undo a 301 redirect simply by changing the response header. However, the changes may not take effect immediately. The search engine crawlers have to re-crawl the page and identify that the response header has been changed.
How long does a 301 redirect last?
301 is a permanent redirect. This means, how long it would last is an irrelevant question. It will be there as long as the response from a URL remains to be 301.
How to Fix 301 Moved Permanently Error?
Before we study whole about the 301 Moved Permanently Error, let’s starts a small discussion upon the redirects.
Are you not familiar with the redirects? Do you ever feel like how to create a redirect in WordPress, why do you need, and when you should use redirects?
The 3xx HTTP Status Code Series
The 3xx HTTP Status Code series indicates that the client must take additional action to complete the request and access the desired resource. Mostly these status codes are used in URL redirection. The 301 redirects are considered best for upgrading users from HTTP to HTTPS.
What is a Redirect in WordPress?
A redirect is a way to send a quick message to your readers to tell them that the page they want to visit has moved, so their browser can automatically point them to the new page of your choice. There are the different type of redirects available, and some of them are 301, 302, and 307 redirects.
What is 301 Moved Permanently?
301 status code indicates that the URL of the requested resources has changed and a new URL is assigned, in the response. In short, it tells that the URL has Moved Permanently and it will pass the 90% of the Search Engine Link Juice to the new URL.
Where is the problem?
The problem is on the Server Side. As I told you, the 3xx series codes are considered to be redirection messages. Such status codes are generated in response when there is an additional action is required to complete the request on the active web server.
The 301 Moved Permanently code shows an issue on the actual web server hosting your website. Most of the web browsers are automatically detect the 301 Moved Permanently response code and process the redirection action automatically.
Let’s have a small example to understand how it occurs.
Suppose you are accessing a URL like http//:tech-banker.com, but the web server is configured to force redirection to a secure version using https. It informs the browser regarding redirecting the request from http://tech-banker.com to the secured https://tech-banker.com.
In most cases, the browser will automatically detect the 301 Moved Permanently response code after that it will read the new location URL and redirect the request to that new location.
Thus, if you attempt to go through http://tech-banker.com right now, you’ll automatically be redirected to the HTTPS version of the site: https://tech-banker.com.
Start With a Backup
Before moving, it is suggested to take a complete backup of your website. You can use any WordPress backup plugin to backup your site. You may use Backup Bank to backup your site. It is freely available on wordpress.org. With the help of Backup Bank, you can take backup manually even you can also schedule your site back up.
Diagnoses for 301 Moved Permanently Response Code
The 301 Moved Permanently indicates that the URL or resources you are trying to access are not valid and must be redirected to a new URL.
Here are some steps that may help you in troubleshooting this error.
Method 1) Check the Server Configuration Files
Apache or Nginx are the two most popular web servers. Your site is probably running on one of these web servers. Thus, the first step you can take to determine the cause of 301 response code is to check the configuration files for your web server.
If you are on Apache Web Server then, Look for a .htaccess file within the root directory of your website file system. You can find the file at /home//public_html/.htaccess . If you found the .htaccess file, open it in a text editor and look for RewriteXXX directives, which are part of the mod_rewrite module in Apache.
These directives define a text pattern that will match against the requested URL.
RewriteCond directives are used to perform the actual redirection of the request to the appropriate URL. If you find any strange RewriteCond or RewriteRule directives in the .htaccess file, try temporarily commenting them using the # character prefix and restarting your web server to see if the issue resolved or not.
You can also try deleting the .htaccess file and recreate it. It is quite easy to recreate a .htaccess file. Here are the steps:
1. Login to your WordPress admin and navigate to the Settings Menu.
2. Move to the Permalinks Menu and click on the Save Changes button.
This way, you have a new bug free .htaccess file. On the other hand, if your server is running on nginx then, you’ll need to look for an entirely different configuration file.
nginx.conf is the file and is located in: /usr/local/nginx/conf, /etc/nginx or /usr/local/etc/nginx
Once found, open nginx.conf in a text editor and look for the rewrite directives. Check for any abnormality and comment them out before restarting the server to see if the issue was fixed.
Method 2) Check the Logs
Logs provide the details about the health and status of all the server. They tell about the nature and the type of the error. They tell, on which file it is appearing, line number where it is appearing. By so, it becomes easy to detect and correct the error.
Method 3) Custom Code or Script File
It may be that your custom code is generating the error. Try to diagnose the issue by manually debugging your custom code. Remove the code snippet or the file and check the tab with the error.
Why do you need to use a 301 Moved Permanently?
Let’s take a look at why it is necessary to understand the use of 301 redirects. The reason to use 301 HTTP Status Code is you want your user to redirect to a new page when a page or post on your site has moved permanently.
Below are some points that will show you when you need to use a 301 redirect in WordPress.
1. When you plan to delete a post or page.
2. When you plan to change the permalinks of your post or page.
Now, the answer to why you need to create a 301 redirect is, it will not only save your website from showing the 404 Not Found message on your screen but also save it from degrading the site’s search engine ranking.
The 301 Moved Permanently error, tells search engines that the page you are trying to access has permanently moved to a new location.
Conclusion
It’s recommended to set up 301 redirects in WordPress when you change the URL (permalinks) of your posts and pages or move your website from one domain to another. The 301 redirects are considered best for upgrading users from HTTP to HTTPS.
WordPress Plugins
-
Backup Bank -
Captcha Bank -
Captcha Booster -
Clean Up Booster -
Clean Up Optimizer -
Coming Soon Booster -
Contact Bank -
Facebook Like Box -
Gallery Bank -
Gallery Master -
Google Maps Bank -
Limit Attempts Booster -
WP Mail Bank -
WP Mail Booster
Здравствуйте, уважаемые друзья и гости блога! Сегодня пойдет речь о такой странной вещи на сайте, как ошибка 301 Moved Permanently (переехал навсегда) или по другому редирект 301.
Думаю. что все с таким сталкивались, а некоторые даже использовали данную “ошибку 301” на своих сайтах. Но не все знают для чего эта ошибка 301 или иначе редирект 301 нужна на сайте? Для чего он, 301 редирект, используется?!
Вот сейчас мы с вами и займемся разбором этого вопроса во всех его подробностях и нюансах …
Ошибка 301 или редирект 301 что это?
Как Вы уже наверное догадались по переводу слов “moved permanently” – это дословно, что сайт или отдельная его страница “переехал навсегда” по адресу на который Вас перекинул ваш браузер. Тут надеюсь все понятно и ясно без лишних пояснений!
Но возникает вопрос. Для чего это сделано вебмастером этого сайта? Почему он поставил редирект 301 и у нас с вами выскакивает иногда 301 ошибка? А все просто! Ошибка 301 появляется, когда сервер перебрасывает нас с уже не работающего сайта на страницу сделанную специально для перенаправления пользователя на рабочий сайт, но просто с некоторой задержкой или вообще на этой странице нужно самостоятельно перейти по ссылке. Вот это в двух словах об ошибке 301.
Теперь самый важный момент, зачем же все таки нужен редирект 301 на сайте …
Редирект 301 и для чего он нужен?
Есть несколько причин у вебмастера, чтобы использовать редирект 301. Вот они:
- Причина первая: Склейка домена с www и без www. При этом все seo показатели сайта и его ссылочный вес будут совмещены и не будут отличаться друг от друга.
- Причина вторая: Если вдруг пришлось сменить домен для сайта. Тогда применяется редирект 301 и он как раз перенаправляет посетителя сайта и поисковые роботы на рабочий домен сайта. Это также позволит вам сохранить все seo показатели вашего переехавшего сайта, как тИЦ, PR, так и своих посетителей.
- Причина третья: Использование редиректа 301 при переносе отдельной страницы сайта на другой ресурс. Бывают и такие случаи, когда это нужно сделать.
- Причина четвертая: Например у Вас есть сайт, где высокий тИЦ и PR и много посетителей. И еще есть другой сайт, который нужно немного пропиарить и прибавить к нему посещения. Тогда Вы просто на просто перенаправляете при помощи того же редирект 301, с одной страницы высоко посещаемого сайта на страницу более низко посещаемого сайта и тем самым выигрываете, добавив ему веса ссылочной массы и соответственно посещений.
Вот основные причины для использования редирект 301 или ошибка 301 Moved Permanently.
Теперь давайте узнаем, как правильно использовать редирект 301 на своем сайте и как настроить его через файл htaccess …
301 редирект и файл htaccess – как правильно настроить?
Как я вам уже говорил выше – 301 редирект это переадресация посетителя и поискового робота на сайт или отдельно взятую страницу сайта на URL адрес отличный от первоначально запрошенного в браузере.
Для чего это нужно мы с вами также уже разобрали. Но как же это сделать правильно на нашем сайте используя файл htaccess? Сейчас я вам все подробно объясню и приведу примеры внесения изменений в файл htaccess для вашего сайта!
- Перенаправление домена с www на без-www
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
или вот более понятный синтаксис:
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
- 301 редирект запросов без-www на домен с www префиксом
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Альтернативный вариант:
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.(.*) [NC] RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
- 301 редирект старого домена на новый в фале htaccess
Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
- Если вам нужно, чтобы вместо rewrite.htm загружался файл rewrite.html, добавьте в файл htaccess вот это:
RewriteEngine on RewriteBase / RewriteRule ^rewrite\.htm$ rewrite.html [R=permanent]
- Чтобы заменить все .htm файлы на .html внесите в файл htaccess:
RewriteEngine on RewriteBase / RewriteRule ^(.*)\.htm$ $1.html [R=permanent]
- Варианты, когда не нужно использовать 301 редирект на вашем сайте:
- Если реализация 301 редиректа невозможна или она займет неоправданно много времени.
- Если контент вашего сайта дублируется на двух или нескольких страницах, но эти страницы должны быть доступны в поиске пользователю ввиду некоторых отличий (на пример, выбор какого-то товара).
- Если одна страница имеет несколько URL адресов (сортировка каталога товаров по различным категориям или критериям).
- Для кросс-доменов. Это, когда контент сайта на двух URL адресах дублируется, но он должен быть доступен на каждом из двух или нескольких доменах.
Этот материал посвящен выходу 301-ой статьи на моем блоге!
Может вам интересно узнать, что такое ошибка 503 и как ее устранить?
На этом пока все. Всем удачи и благополучия!
Introduction
Learn about 301 redirects and the most common errors so you can avoid them in
the future. Fortunately, you’ve found your way here.
Think of it as if you’re creating a brand new webpage or an entire website
from scratch. Alternatively, you may be moving your website. Your domain name
may contain a typo. You’ve concluded that using the same URL is no longer
feasible. What are you doing?
A 301 permanently relocated status code is what you use. The purpose of these
codes is to redirect your customers to a different location. «The requested
document has been permanently relocated.» Users will try to access a page, but
will instead be redirected elsewhere.
You need to know the
301 status code, as well as how to find and fix 301 errors, here.
What Does 301 Permanently Moved Mean?
HTTP status codes
come in a wide variety of flavors. There are a variety of ways to tell the
user if a specific HTTP request has been successful. In total, there are five
levels:
-
Responses that provide data (such as 100 Continue and 101 Switching
Protocols) - Successful outcomes
- Reroutes traffic
-
Mistakes by the user (like
404 Page Not Found) - as well as server issues
There is a redirection indicated by the 3xx HTTP status code. Instead of the
original URL, users and search engines will be redirected to a new one. There
are a variety of 3xx status codes, such as 302, 303, and 307, each with their
unique interpretation.
301 status codes should be used when you’re permanently changing one URL for
another. In other words, the old URL will be redirected to the new one for
people and bots alike.
Website.com/blog redirects to blog.website.com
It would sound something like this to a real person:
Visitor: For the time being, this page has been relocated, and we have
no plans to return it.
Browser: I see now. I’ll direct your existing customers to the new
URL.
There will be no need for the old URL, as it will no longer appear in the
search results. The old URL’s link equity will be transferred to the new
URL.
As a result, whenever you’re doing a site migration or removing an old page
and replacing it with a new one, you’ll want to perform a 301 Moved
Permanently redirect.
How do 301 and 302 redirections differ?
A 301 redirect is superior to a 302 redirect. Have trouble deciding which
one to use?
The fact that you’re feeling this way isn’t unique.
Even in 2019, website owners are unsure of which type of redirect is best for
search engine optimization (SEO).
A redirect can be useful for a variety of reasons. Below are the most
frequently used justifications:
- You’ve launched a brand-new site.
- Creation of a new page for you.
- There is a problem with your URL.
For example, you’re working on an issue with a page and want to redirect users
to another page.
The decision is heavily influenced by the redirect’s intended outcome. When it
comes to SEO, it’s important to know the difference between the two.
Search engines need to be informed that a website or page has been permanently
relocated by a 301 redirect. If you’re moving a website or creating a new one,
you should use an HTTP 301. Usage of 301 is appropriate if you’re joining two
websites together. However, 301 is also useful if you’re making modifications
to the URL that are not meant to be reversed.
Using a 302 redirect lets search engines know that a website or page has been
temporarily redirected elsewhere. If you’re redesigning or updating a website
or a page, you should use this redirect. You can also use the redirect to test
out a new page and get feedback from customers. Only use a 302 redirect if you
intend to bring the old website or page back online in the future.
A 301 redirect lasts how long?
It is typical for a 301 redirect to remain in place for a year or more. Check
to see if you’re new URL is still being sent to users after that.
Fixing 301 redirects is a question I frequently get
Error 301 is a common occurrence for website owners of all skill levels. To
keep your website in good working order, it’s important to know what’s wrong
and how to fix it. When dealing with these kinds of issues, regular website
maintenance is a must, and here are the most common and best ways to resolve
them.
Check to see if your HTTP version is redirecting to your HTTPS version.
Using HTTPS on your site can help protect the personal information of your
site’s visitors. For additional information, Google uses HTTPS as a ranking
factor. To put it another way, not encrypting your website traffic with HTTPS
can harm your search engine results. For the sake of everyone’s safety online,
Google hopes that this move will encourage all website owners to make the
switch from HTTP to HTTPS. It’s 2019 and HTTPS is a no-brainer.
However, if your users are not redirected to the secure HTTPS version, using
HTTPS is of no use. In other words, you’ll need to use an HTTP 301 to switch
between HTTP and HTTPS.
Check the URL bar of your homepage to see if the 301 redirect works between
your two versions. The following is what you’ll see:
https://www.technologycrowds.com/
Enter the URL
https://www.technologycrowds.com/ by removing the «s» from the beginning. A redirect to the secure HTTPS
version of your site should occur if all goes well.
Get rid of all of the 301 redirects on your website
To better crawl your site, Google consults your
sitemap
file. However, since your redirected pages don’t exist, Google has no reason
to crawl them.
301 error status codes can be removed by performing the following steps:
Yourdomain.com/sitemap.xml can be found at this location (keep in mind that
your sitemap URL might be different as there are exceptions).
Use a URL Extractor to download a list of all of your URLs in one place.
- Use any free tool to paste the list.
- Use a 301 status code to narrow the results.
- Replace the 301 URLs in the sitemap file with the final URL.
- Delete the 301 URLs from the sitemap file.
- Redirect chains are to be avoided at all costs.
When the original URL and the final URL are connected by more than one
redirect, this is known as a redirect chain. If you want to see an example of
this, look at Page 1. Nevertheless, Google cautions against the use of
redirect chains, citing the negative impact on user experience (UX) and the
resulting slowdown on site performance.
Link farms are bad for SEO, too. Only about 85% of link equity is passed
through 301 redirects, according to industry estimates. In other words, the
more redirects there are, the worse the situation.
Ensure that the final URL is redirected to. A few pointers:
Redirect chains can be found using a tool like this.
The redirect chain should be replaced with a single 301 redirect once you’ve
found them. In place of Page 1, Page 2, and then Page 3, the redirect goes to
Page 1 and then Page 3.
In addition, you can replace internal links to redirected pages with direct
links to the final URL.
Remove redirect loops
URLs that are linked together can create a redirect loop when one of them
redirects users back to another URL. There are many examples of this, such as
the following:
As soon as possible, you’ll want to address this problem.
Use a free tool to scan up to 100 URLs for errors indicating that the maximum
number of redirects has been exceeded.
You can fix redirect loops in two ways once you find them:
If you don’t want the URL to redirect, change the HTTPS response code to
200.
You should fix the final destination URL if the URL is supposed to reroute.
Your redirects need to be fixed.
If a link is broken, it takes you to a page that doesn’t exist! Page 1 (301)
> Page 2 (302), for example (404). Your website’s search engine rankings
and user experience could suffer as a result.
To check for broken redirects in batches of 100, use the tool we mentioned
above.
You can fix any errors you find by:
- Reviving a long-dead page
- Deleting the redirected URL’s in-links.
Redirects from 302 to 301 should be used instead.
If you want to move permanently, you should never use 302 redirects. Removing
or replacing an HTTP response status code 302 redirect that is in place
because of a long-term move is the best course of action.
301 redirect pages that receive traffic should be examined.
This code tells the browser that a page has permanently relocated to a new
URL. There should be no organic traffic to that page. Chances are that Google
will notice the HTTP 301 if you recently added it.
Use a tool like Moz, SemRush, or Ahrefs to look for redirected pages that are
still receiving organic traffic.
Remove the pages from your sitemap and re-submit them through Google Search
Console once you’ve located them.
The most important things to remember
A 301 redirect is a permanent way of sending a URL to a new location. Search
engines and website visitors alike will be alerted to the URL’s new location
if you do this.
You must have a strategy in place and use redirects wisely. Organic traffic
can be greatly increased by correctly implementing HTTP 301. Follow the advice
above if you’re concerned that your website has unresolved 301 Moved
Permanently errors.