The solution to 404 error is returned for the encoded Chinese URL, url404. After accessing the encoded Chinese URL, 404 error is returned. url404 made a project yesterday. one of the requirements is that each image corresponds to a short text description of the image, solution to the error 404 returned by a common Chinese URL encoded after access, url404
A project was created yesterday. one requirement is that each image corresponds to a short text description of the image, A common practice is to create a new table and record the image name and description in the database. After careful consideration, I feel that this application can be completed without a database. the solution I implemented is to use URLENCODE as the file name, in this way, when I read the file, I can use the file name URLDECODE to describe the text of the image after the drive.
However, when accessing images through a browser, the system prompts that the file cannot be found. for example, the description text of an image is "Qiongtai Blog". the file name generated after URLENCODE is as follows:
The code is as follows:
%E7%90%BC%E5%8F%B0%E5%8D%9A%E5% AE %A2.jpg
So I accessed the image through a browser and prompted that the image could not be found.
After careful reading, I found that the file name was automatically transferred back to Chinese when the browser accessed it.
Firefox
Chrome
IE
Safari
IE and Safari do not see the conversion from the address bar to Chinese characters, but they also prompt that the file cannot be found. But I think it should have been automatically converted during the request, but the address bar does not show the converted ones. View the requests for accessing images from Nginx access records
The code is as follows:
192.168.6.30--[12/Oct/2012: 10: 09: 44 + 0800] "GET/clusters HTTP/1.1" 404 199 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0 )"
No exception was found in request URL processing. finally, after studying the encoded file name repeatedly, it was found that all the results were composed of a percent sign and a letter number, I think the browser may perform some other conversions when it encounters a percent sign, so the prompt that the file after the browser accesses URLENCODE cannot be found.
So I replaced all the percentage signs in the file names after URLENCODE with underscores.
The code is as follows:
%E7%90%BC%E5%8F%B0%E5%8D%9A%E5% AE %A2.jpg
Replace
The code is as follows:
_E7_90_BC_E5_8F_B0_E5_8D_9A_E5_ AE _A2.jpg
Solve the problem by re-accessing the browser
To obtain the text description of an image, replace "_" in the file name with "%" and then use URLDECODE.
Note that the file name in Linux has the same length limit as that in Windows. Currently, the most common format is ext3, which can contain 255 characters, after about five characters are deducted as extended names, there are about 250 pure-length file names remaining, and the length of one Chinese character after URLENCODE is 9. Therefore, a maximum of 27 Chinese characters can be encoded as file names..
Although this method stores fewer Chinese characters, you can use some encryption methods to obtain a short string of ciphertext, and then URLENCODE the ciphertext. I will not give an example of the specific implementation method, start thinking about it!
Why is a 404 error reported on the website? how can this problem be solved?
404 is an HTTP status code. the emergence of HTTP 404 status code means that the webpage to which the link is directed does not exist, that is, the URL of the original webpage is invalid. this situation often occurs, especially for large websites, it is hard to avoid. for example, the original URL address cannot be accessed because the webpage URL generation rules are changed, webpage files are renamed or moved, the import link is misspelled, and the editing or program staff are negligent; when the Web server receives a similar request, it returns a 404 status code, telling the browser that the requested resource does not exist. The cause of this error is generally caused by a website issue: The webpage URL itself has changed, but the front-end page has not been updated in a timely manner; the webpage itself or the location of the webpage file has changed, not updated in the background in a timely manner; external links are misspelled; website content administrators or program administrators do not take into account the processing URL. for example, if link attributes are added to some places, the URL cannot be accessed normally. The user's network environment causes: The requested Port cannot ** ask the URL address of the webpage. The Web service extended locking policy blocks this request. The MIME ing policy blocks this request. For small website administrators who have less content on the webpage, you can use the dead link detection tool “xenu.exe to detect dead links on the webpage and process the error link information in a timely manner. for large and medium-sized website administrators who have more content, using the dead link detection tool above may consume a lot of time, you can pay attention to the status code of users in the daily website log files and discover and promptly resolve the 404 error. Create a friendly 404 error page to remind users of access error information, guide users to search for the home page or directory, and provide the site search function or website administrator contact information. For SEO personnel (search engine optimization workers), we recommend that you refer to the article "404 error will affect the website" for more information. Common users: try to change the browser or clear the browser cache (exclude access failures caused by browser controls or malicious plug-ins) check whether a user has the network connection permission (some computers may be set to a limited time or restrict network connections) to check whether the network environment is normal (security detection or anti-virus software can be used for detection) check whether there are restrictions on the running of programs on the computer (some computers may be set to control the network connection permission by software, and a password is required to connect)
404 how to solve webpage errors? Anxious
The 404 page is the page returned when the user inputs an incorrect link. 404 the purpose of the page is to tell the viewer that the requested page does not exist or the link is incorrect. at the same time, the user is guided to use other pages of the website instead of closing the window and leaving. 404 impact on seo custom 404 error pages is a good way to enhance user experience, but the impact on search engines is often not noticed in the application process, such: if the server configuration is incorrect, "200" status code is returned or the custom 404 error page uses Meta Refresh to return "302" status code. A correctly set custom 404 error page should not only be correctly displayed, but also return the "404" error code instead of "200" or "302 ". Although there is no difference between the HTTP status code "404" and "200" for the Accessed users, it is very important for the search engine. When a search engine spider returns a 404 status response when requesting a URL, it knows that the URL has expired and no longer indexes the webpage, and report to the data center that the webpage indicated by the URL is deleted from the index database. of course, the deletion process may take a long time. when the search engine gets the "200" status code, the url is regarded as valid, and then indexed and indexed to the index database. The result is that the two URLs have identical content: customize the content of the 404 error page, which may cause the copy webpage problem. If it is light, it is downgraded by the search engine. if it is heavy, it will kill the website. How to achieve a good 404 page to change the default server error page can achieve the effect. The following are some suggestions for making it easy for visitors to access the website.
Concept
Provides concise problem descriptions to eliminate visitor frustration. Provide reasonable solutions to help visitors complete access targets. Provides a personalized and user-friendly interface to improve the access experience.
User Guide
Implementation Method (arranged in a simple to complex order): Enables the visitor to go somewhere rather than backward. The page contains links to important parts of the site, such as the home page or site map. Do not just tell them to check spelling. Use text links instead of images, because many visitors do not want to click the image. Example: Our website has a home page return link. This is the minimum level for friendly feedback. In addition, we will also consider how to make up for errors through visitor feedback when there is insufficient effective help information. You must include an email link pointing to the website administrator or a table used to submit the lost link. Compared with sending emails, visitors prefer to use the submit form. Add a search box to search for the site. For example, MSN has a search box at the bottom of all pages and links them to an important part of the site. List links close to the visitor's desired page on the site to speculate on the page the visitor is looking. You do not need to adopt all the above suggestions, but these suggestions serve the purpose of making visitors more willing to stay on your site. A reasonable 404 error page can be completed now, which will provide valuable information to visitors. 404 error page setting Method: 1. if the webpage content cannot be accessed due to a path change, you can define a 404 error in IIS to point to a dynamic page, and use 301 to redirect permanently to a new address in the page, in this case, the server returns the 301 status code. 2. set 404 to point to a designed html file. The 404 status code returned by the page is displayed. Currently, idc providers basically provide the 404 setting function, which allows you to directly upload File settings. How to set in IIs: open IIS Manager --> click the properties of the website for which you want to set custom 404 --> Click Custom Error options --> select page 404 --> Select and open edit attributes --> set to URL --> enter "/err404.html" in the URL --> return the URL and upload the err404.html page to the root directory of the website. In "message type", you must select "file" or "default value" instead of "... the remaining full text>
Xiaoming made a project yesterday. one of the requirements is that each image corresponds to a short text description of the image...