After accessing the encoded Chinese URL, return the 404 error resolution, url404
Yesterday to do a project, one of the requirements is that each picture corresponds to a small paragraph of text on the picture description, the common practice is to create a new table and then the picture name and description text are recorded in the database. After careful consideration of this application do not feel the database can also be completed, I realized the scheme is to use the description text UrlEncode as a filename, so when I read the file and then the filename urldecode can drive the text description of the picture.
However, the browser to access the picture when the file is not found, if there is a picture of the text is "Jones Taiwan blog", UrlEncode generated after the file name is as follows
Copy the Code code as follows:
%e7%90%bc%e5%8f%b0%e5%8d%9a%e5%ae%a2.jpg
So I access the picture through the browser, the hint can't find
Take a closer look and find that the browser automatically turns the file name back to Chinese when it is accessed.
Firefox
Chrome
Ie
Safari
IE and Safari from the address bar did not see the conversion to kanji, but also prompted to find the file. But I feel that it should be when the request is also automatically turned, but the address bar is not displayed after the conversion. From Nginx access record to see the request when the picture is accessed
Copy the Code code as follows:
192.168.6.30--[12/oct/2012:10:09:44 +0800] "GET/%e7%90%bc%e5%8f%b0%e5%8d%9a%e5%ae%a2.jpg http/1.1" 404 199 "-" "Mozil la/5.0 (compatible; MSIE 9.0; Windows NT 6.1; trident/5.0) "
Request URL processing did not find anything unusual, and finally through the repeated study of the encoded file name, found to be composed of a percent sign and alphanumeric, I feel it should be the browser in the face of the percent sign may do some other conversion processing, so that the browser access to UrlEncode after the file hint can not be found.
So I replaced all the UrlEncode in the file name with an underscore.
Copy the Code code as follows:
%e7%90%bc%e5%8f%b0%e5%8d%9a%e5%ae%a2.jpg
Replaced by
Copy the Code code as follows:
_e7_90_bc_e5_8f_b0_e5_8d_9a_e5_ae_a2.jpg
Re-use browser access, problem solving
If you want to get the text description of the picture, simply replace the "_" of the file name with "%" and then use UrlDecode.
Finally, it should be noted that the Linux file name is the same as the win system has a length limit, the most commonly used format is EXT3, this format allows 255 character length, minus about 5 as the extension after the name of about 250 length of the remaining pure file name, And a Chinese character after urlencode the length of 9, so the maximum can encode 27 characters as the file name .
Although the Chinese characters stored in this way are relatively small, but can use some encryption methods to obtain a short string of ciphertext, and then the ciphertext UrlEncode can, the specific implementation of the way I do not give an example, do think about it!
Why does the website have 404 errors, how to solve
404 is an HTTP status code, the presence of an HTTP 404 status code means that the link to the page does not exist, that is, the URL of the original page is invalid, this situation often occurs, especially for large web sites, it is difficult to avoid, such as: Web page URL Generation rules change, page file renaming or moving location, Import link spelling error, editing or program staff negligence, etc., resulting in the original URL address is inaccessible; When the Web server receives a similar request, it returns a 404 status code telling the browser that the resource being requested does not exist. The cause of this error in general, there are: the site itself problems caused: The Web page URL itself has changed, and the front page is not updated, the page itself or the location of the page file changes, but not timely in the background updates; external links spelling error; The Site Content Manager or program administrator does not take care of the URL, for example, if a link attribute is added to the URL, it cannot be accessed properly. The user's network environment caused: Could not ask the Web page URL address on the requested port. The Web service extended lockdown policy blocks this request. The MIME mapping policy blocks this request. For small web site administrators with less content, you can use the Dead link detection Tool "xenu.exe" to detect the dead link of the Web page, to find and timely handle the wrong link information; for large and medium-sized web site administrators with more content, using the dead link detection tool above may take a lot of time, Can focus on the daily site log files in the user status code situation, found and timely resolve the 404 error problem. Make a friendly 404 error page, remind users to access error messages, guide users to the homepage or directory search, provide the site search function or webmaster contact information. For SEO staff (search engine optimization workers), it is recommended to refer to the "404 error will affect the site" article for more information. Normal User: Try to change the browser or clean up the browser cache (excluded due to browser controls or malicious plug-ins, etc.) to see whether the current user has network link permissions (some computers may be set limited time or limited network link) to detect whether their network environment is normal ( Can be detected by security detection or anti-virus software to detect whether there is a relevant restrictions on the computer program run (some computers may be Software Settings control network link permissions, need password to link)
404 page error How to solve? Nasty in the crazy
404 page is the page that is returned when the user enters the wrong link. 404 The purpose of the page is to tell the browser that the requested page does not exist or link the error, while directing the user to use other pages of the site instead of closing the window to leave. 404 Impact on SEO customizing the 404 error page is a good practice to enhance the user experience, but often does not notice the impact on the search engine in the application process, such as: Incorrect server-side configuration results in the return of "200" status code or custom 404 error page Using Meta Refresh causes return " 302 "Status code. The custom 404 error page that is set correctly should not only be displayed correctly, but should also return a "404" error code instead of "200" or "302". Although there is no difference between the HTTP status code of "404" or "200" for the user, it is very important for the search engine. When a search engine spider receives a "404" status response when requesting a URL, knowing that the URL is invalidated, the page is no longer indexed, and the Web page represented by the URL is deleted from the index database to the data center, although the deletion process can take a long time, while the search engine gets "200" Status code, the URL is considered valid, it will be indexed, and will be ingested into the index database, the result is that these two different URLs have exactly the same content: Custom 404 error page content, which will lead to replication Web page problems. Light is the search engine down the right, heavy will k off the site. How to achieve a good 404 page change server default error page can achieve the effect. Here are some suggestions that make it easy for visitors to get regular access.
Follow the concept
Provide a concise description of the problem and eliminate the frustration of visitors. Provide a reasonable solution to assist visitors to complete the access target. Provides a personalized, user-friendly interface to enhance the access experience.
User Guide
Implementation (in order from simple to complex): Allows a visitor to go somewhere rather than back. Pages contain links to important parts of the site, such as the home page or sitemap. Don't just tell them to check the spelling. Use the text link instead of the picture, because there are many visitors who would not want to click on this image. Example: Our site has a return link to a home page. This is the minimum to achieve friendly feedback. In addition, we will consider how to compensate for errors with the feedback of the visitor in case of insufficient help information. You need to include an email link to the webmaster, or a form to submit the missing link. Visitors prefer to use the submission form relative to sending an email. Add a search box to search for sites. Example: MSN has a search box at the bottom of all pages, and also links to important parts of the site. A link to the page that is close to the visitor's expectation is listed in the site to speculate on the page the visitor is looking for. You do not need to adopt all of the above suggestions, but these recommendations are consistent in serving the purpose of making visitors more willing to stay on your site. A reasonable 404 error page can now be completed, which will give visitors a lot of valuable information. 404 error Page Setup method: 1. When the content of the Web page is not accessible because of a path change, you can define a 404 error in IIS to point to a dynamic page, and use 301 permanent redirection to jump to the new address in the page, when the server returns a 301 status code. 2, set 404 point to a well-designed HTML file, this time the page returns the 404 status code. Now the IDC provider basically provides 404 set of functions, directly upload file settings. To set the method in IIS: Open IIS Manager-click the properties of the Web site you want to set custom 404-click Custom Error Options--select 404-page to select and open Edit Properties-set to URL--fill in the URL-- Err404.html "-Press OK to exit and then upload the good err404.html page to the Web site root directory. Here, in message type, be sure to select file or default, instead of selecting ... Remaining full text >>
http://www.bkjia.com/PHPjc/866671.html www.bkjia.com true http://www.bkjia.com/PHPjc/866671.html techarticle after accessing the encoded Chinese URL return 404 error resolution, url404 yesterday to do a project, where there is a requirement is each picture corresponding to a small paragraph of text on the picture of the description, the ordinary do ...