WordPress knowledge sharing

The website image does not display the prompt 403 Forbidden resolution process record

After the website moves Website picture cannot be displayed This is a problem that many webmasters will encounter. There are many reasons for the problem. Today, Wei Aisi met a netizen who moved from Alibaba Cloud lightweight application server to Alibaba Cloud ECS server , the picture cannot be displayed after it is still good. Since we encounter problems, we must find ways to solve them.

Introduction to website

The website is placed in Alibaba Cloud's lightweight application server. Because the renewal fee is expensive soon (the peak bandwidth of 8M of 1-core 2G memory is more than 1600 yuan/year), and the price of ECS server promotional activities is very cheap (the shared s6 server with 5M of 2-core 4G memory is more than 1300 yuan/3 years), we plan to move in the past. So from Alibaba Cloud · Cloud Xiaozhan promotional activity page After purchasing the above server, we began to deploy the pagoda panel, backed up the website on the old lightweight application server, and moved.

The moving process was very smooth, and website files and databases were uploaded to the server. Because of the large number and size of website images, AliCloud CDN has always been used to store images with AliCloud OSS objects.

As a result, all the pictures on the website could not be displayed after the move.

Analysis and troubleshooting process

After a lot of analysis, the following elements were checked:

  • OSS plug-in parameters, test reading, writing and deletion are normal;
  • The WordPress background media library is replaced by the OSS plug-in. The uploaded images are large and numerous, so they are directly transferred to Alibaba Cloud OSS. The product images are not retained, and only a few images used by programs are on the server;
  • The problem of uninstalling plug-ins and reinstalling them remains;
  • The Access Key and Secret Key have not been changed;
  • AliCloud · Cloud resolution, AliCloud cdn and AliCloud OSS are OK, and the IP address has been modified accordingly after the move;
  • The website theme is switched to the 2021 default theme, and the image is still not displayed;
  • The SSL certificate has been added to the cdn and pagoda panels, and is displayed normally;
  • WordPress can normally open front and rear pages;
  • 301 redirection in the pagoda panel has been set;
  • The object-cache.php file has been added. Memcached is installed and takes effect;
  • To solve the problem, the website is deleted and rebuilt (files and databases are not deleted), but still not displayed;
  • The webp image compression function that comes with the theme has also been canceled, and the image is still not displayed;
  • nginx、php、mysql、 The server has also been restarted, which is invalid;
  • Cdn has been refreshed repeatedly;

Not limited to the above solutions, almost all the solutions to the problem have been tried, but the pictures are still not shown.

Then check the specific reason why the image is not displayed. Press F12 developer tool in the browser, and then press F5 to refresh the front page. There are a large number of red status: 403 image files, which are exactly the images that are not displayed. Click the picture and then click Preview on the right side of the page to display 403 Forbidden, as shown in the following figure:

The English prompt means that the server does not have permission to access files in AliCloud OSS. It seems that the problem is still concentrated in OSS permissions. therefore Open Alibaba Cloud official website directly , enter the OSS management console, find [Permission Management], and carefully consider the options on the right page one by one.

Read/write permission: public read, this is OK;

Access control RAM: the account and password have not been changed;

Immobilizer chain: Now the only suspect is here. Copy any image URL from the website page to the browser, and you can see the image (the source address of the image OSS can be accessed directly). At this time, a friend remembered that the domain name in the WordPress background>Settings is the main domain name (without www) after moving home The 403 status code appears when AliCloud Document>Access OSS AliCloud OSS settings security chain Content. It is preliminarily suspected that the content is not added to the OSS anti-theft chain https://example.com Because of. After manual addition, the picture is displayed, and the problem is solved.

Later, when analyzing the reasons, netizens mentioned:

1. He has always used Google Browser to visit the website, but the address bar of Google Browser only displays the main domain name (even if the www domain name is opened, the www prefix is not displayed). He is not familiar with this aspect, but he thinks that the main domain name of the website has always been the main domain name, which has led to misleading.

2. From the beginning to the end, he stressed to Lao Wei that the main domain name of the website is a domain name without www, and took the initiative to change the two lines of websites in WordPress background>settings to the main domain name.

3. Unfortunately, the main domain name has not been added to the whitelist in the security chain of Alibaba Cloud OSS, so it will be blocked and will not be displayed.

According to Alibaba Cloud OSS anti leech rules, the wildcard asterisk (*) indicates that 0 or more characters are replaced by asterisks. For example, if it is configured as *. example.com, it can match addresses such as help.example.com and www.example.com. But does not match example.com.

The primary domain name MX record conflicts with the cname record

Follow up netizens encountered a new problem as follows:

If the AliCloud primary domain name accesses the website through the cdn, you must add a cname record. If you want to add another MX record (enterprise mailbox), the page will prompt that the MX record conflicts with the cname record. The solution is to add the A record of the main domain name to the server IP address. At the same time, for security, the pagoda panel>security, set the disable ping.

At this time, the MX record of the main domain name can be added normally.

Weiss summary

Finally, the website uses the www.example.com domain name as the primary domain name to provide access and collection, while the real example.com domain name is redirected to the www domain name by 301 in the pagoda panel, and provides services for the corporate mailbox. In this way, the problem at the beginning of this article and the subsequent analysis of the enterprise mailbox are successfully solved. Lao Wei shared the whole operation process to make a record for future search, and also hoped that it would be helpful to friends with the same problem.

Like( zero )
Article name: 403 Forbidden Solution Process Record
Article link: https://www.vpsss.net/24281.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.