Static website hosting method, device, equipment, readable storage medium and server
Through the distributed file storage system and automatic completion technology, the problem of poor flexibility of static website hosting methods is solved, low cost, high scalability and multi-protocol adaptation are achieved, and the flexibility of using static websites is improved.
Patent Information
- Application Number
- CN202310349906.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-03-30
AI Technical Summary
The existing technology lacks a mature static website hosting method, resulting in poor flexibility in the use of static websites.
A static website hosting method is provided. The method utilizes a distributed file storage system to determine whether a web page file reading request points to a specific file. If not, the method completes the file and adapts to different types of protocol requests, thereby achieving automatic completion and multi-protocol adaptation.
It improves the flexibility of static websites, reduces costs, supports requests from multiple protocols, and improves user experience.
Smart Images

Figure CN116541624B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of static websites, and in particular to a static website hosting method. The present invention also relates to a static website hosting device, equipment, computer-readable storage medium and server. Background Art
[0002] A static website is a website composed entirely of HTML (Hypertext Markup Language) code-formatted pages. All content is contained in (static) web page files, and various visual dynamic effects, such as GIF animations, Flash animations, and scrolling subtitles, can also be presented on the web page. For ease of management, static websites can be hosted on a storage system through static website hosting. However, the existing technology lacks a mature static website hosting method, resulting in poor flexibility in the use of static websites.
[0003] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve at present. Summary of the Invention
[0004] The purpose of the present invention is to provide a static website hosting method, which first has the advantages of low cost and convenient expansion of a distributed file storage system, and can also automatically complete the memory of web page file reading requests that do not point to specific files, and can adapt to requests of various different types of protocols, thereby improving the flexibility of static websites; another purpose of the present invention is to provide a static website hosting device, equipment, computer-readable storage medium and server, which first has the advantages of low cost and convenient expansion of a distributed file storage system, and can also automatically complete the memory of web page file reading requests that do not point to specific files, and can adapt to requests of various different types of protocols, thereby improving the flexibility of static websites.
[0005] To solve the above technical problems, the present invention provides a static website hosting method, comprising:
[0006] Determine whether the web page file read request sent by the client points to a specific file;
[0007] If not, the webpage file reading request is completed according to the preset request parsing rules so that it points to a specific file;
[0008] Determining whether the protocol type of the current webpage file reading request is a file storage protocol;
[0009] If it is a file storage protocol, then reading the specific file from the distributed file storage system according to the webpage file reading request and feeding the specific file back to the client;
[0010] If it is not a file storage protocol, the protocol type of the web page file reading request is converted to the file storage protocol, and the steps of reading the specific file from the distributed file storage system according to the web page file reading request and feeding the specific file back to the client are performed.
[0011] Preferably, the determining whether the webpage file reading request sent by the client points to a specific file is specifically as follows:
[0012] Determine whether the webpage file reading request sent by the client contains the name of a specific file;
[0013] If it is included, it is determined that the web page file reading request points to a specific file;
[0014] If not, it is determined that the webpage file reading request does not point to a specific file;
[0015] The webpage file reading request is completed according to the preset request parsing rules so that it points to a specific file:
[0016] If the webpage file reading request does not include a specific file name, then obtaining the index file path from the metadata;
[0017] The web page file read request is completed according to the index file path so that it points to the index file.
[0018] Preferably, after determining that the webpage file reading request points to a specific file, the static website hosting method further includes:
[0019] Determine whether the specific file exists in the directory provided in the webpage file reading request;
[0020] If it does not exist, get the 404 error file path from the metadata;
[0021] The web page file read request is completed according to the 404 error file path so that it points to the 404 error file.
[0022] Preferably, the method of determining whether the webpage file reading request sent by the client includes the name of a specific file is as follows:
[0023] Upon receiving a webpage file reading request sent by a client, determining whether the source of the webpage file reading request is a subdomain;
[0024] If it is a subdomain, it is determined whether the web page file reading request includes the name of a specific file.
[0025] Preferably, if it is a subdomain, determining whether the webpage file reading request contains the name of a specific file is specifically as follows:
[0026] If it is a subdomain, determine whether the file directory to which the webpage file reading request applies for access has enabled the static website hosting function;
[0027] If it is enabled, it is determined whether the webpage file reading request includes the name of a specific file.
[0028] Preferably, after determining whether the file directory to which the webpage file reading request applies for access has enabled the static website hosting function, and before determining whether the webpage file reading request includes the name of a specific file, the static website hosting method further includes:
[0029] If it is enabled, determining whether there is an error in the webpage file reading request;
[0030] If so, determining the error code of the webpage file reading request;
[0031] According to the correspondence between the preset error code and the error file path, determine the error file path corresponding to the error code;
[0032] Completing the webpage file reading request according to the error reporting file path so that it points to the error reporting file;
[0033] If not, execute the step of determining whether the web page file reading request includes the name of a specific file.
[0034] Preferably, the static website hosting method further includes:
[0035] In response to the first update instruction, the correspondence between the preset error code and the error file path is updated.
[0036] Preferably, the converting of the protocol type of the webpage file reading request into the file storage protocol is specifically:
[0037] The protocol type of the webpage file reading request is converted into a Network Attached Storage (NAS) protocol.
[0038] Preferably, after determining whether the webpage file reading request sent by the client includes the name of a specific file and before determining whether the protocol type of the current webpage file reading request is a file storage protocol, the static website hosting method further includes:
[0039] If it is included, determining whether the target keyword exists in the name of the specific file included in the web page file reading request;
[0040] If so, the target file corresponding to the target keyword is determined according to the preset correspondence between the keyword and the file;
[0041] The web page file reading request is updated according to the path of the target file.
[0042] Preferably, the target file corresponding to the target keyword is determined based on the preset correspondence between the keyword and the file, specifically:
[0043] Determining the target file name corresponding to the target keyword based on the preset correspondence between the keyword and the file name;
[0044] Determine the target file corresponding to the target file name.
[0045] Preferably, the static website hosting method further includes:
[0046] In response to the second update instruction, the correspondence between the preset keywords and the file names is updated.
[0047] To solve the above technical problems, the present invention further provides a static website hosting device, comprising:
[0048] The first judgment module is used to judge whether the webpage file reading request sent by the client points to a specific file, and if not, trigger the completion module;
[0049] The completion module is used to complete the webpage file reading request according to a preset request parsing rule so that it points to a specific file;
[0050] a second determination module, configured to determine whether the protocol type of the current webpage file reading request is a file storage protocol, and if so, trigger the reading module; if not, trigger the conversion module;
[0051] The reading module is configured to read the specific file from the distributed file storage system according to the webpage file reading request and feed the specific file back to the client;
[0052] The conversion module is used to convert the protocol type of the web page file reading request into the file storage protocol and trigger the reading module.
[0053] To solve the above technical problems, the present invention further provides a static website hosting device, comprising:
[0054] memory for storing computer programs;
[0055] The processor is configured to implement the steps of the static website hosting method described above when executing the computer program.
[0056] In order to solve the above technical problems, the present invention further provides a server, comprising a server body and the above-mentioned static website hosting device connected to the server body.
[0057] To solve the above technical problems, the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the static website hosting method described above are implemented.
[0058] The present invention provides a static website hosting method. The present application can realize the static web page hosting function based on a distributed file storage system. First, it has the advantages of low cost and convenient expansion of the distributed file storage system. In the process of obtaining network content, even if it does not point to a specific file, the static website hosting method of the present application can also complete the web page file reading request according to the preset request parsing rules so that it points to a specific file, thereby improving the flexibility of using the static website. In addition, the static website hosting method of the present application can adapt to requests of multiple different types of protocols, so that users can obtain web page files through requests of multiple protocols, further improving the flexibility of using the static website.
[0059] The present invention also provides a static website hosting device, equipment, computer-readable storage medium and server. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the prior art and the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0061] Figure 1 A schematic diagram of a static website hosting method provided by the present invention;
[0062] Figure 2 A schematic structural diagram of a static website hosting device provided by the present invention;
[0063] Figure 3 A schematic diagram of the structure of a static website hosting device provided by the present invention;
[0064] Figure 4 A schematic structural diagram of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION
[0065] The core of the present invention is to provide a static website hosting method, which first has the advantages of low cost and convenient expansion of a distributed file storage system, and can also automatically complete the memory of web page file reading requests that do not point to specific files, and can adapt to requests of multiple different types of protocols, thereby improving the flexibility of static websites; another core of the present invention is to provide a static website hosting device, equipment, computer-readable storage medium and server, which first has the advantages of low cost and convenient expansion of a distributed file storage system, and can also automatically complete the memory of web page file reading requests that do not point to specific files, and can adapt to requests of multiple different types of protocols, thereby improving the flexibility of static websites.
[0066] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0067] Please refer to Figure 1 , Figure 1 A schematic diagram of a static website hosting method provided by the present invention, wherein the static website hosting method includes:
[0068] S101: Determine whether the webpage file reading request sent by the client points to a specific file;
[0069] Specifically, considering the technical problems in the above background technology, in order to achieve a more efficient and reliable web hosting function, the embodiment of the present invention needs to process the web page file reading request sent by the client so as to feed back the corresponding web page file to the client, so that the client can use the received web page file to generate the corresponding web page, thereby realizing the function of generating web pages based on static files, that is, static web pages.
[0070] Among them, considering that for a certain website, the user can add the specific directory and file to be accessed after the subdomain name to point to, thereby pointing to a specific web page file, but in some cases the user does not know the specific directory and specific file under the website, so it is necessary to enter the index page of the website, which can also be understood as the main page. In response to such different usage requirements, the embodiment of the present invention can determine whether the web page file reading request sent by the client points to a specific file, so as to trigger different actions according to the judgment result, so that the web page file reading request sent by the user may not point to a specific file, thereby improving the flexibility of using static web pages.
[0071] The web page file requested by the client may be stored in a variety of storage systems, such as a distributed file storage system, etc., which is not limited in the embodiment of the present invention.
[0072] S102: If not, the webpage file reading request is completed according to a preset request parsing rule so that it points to a specific file;
[0073] Specifically, in order to implement the processing of web page file reading requests that do not point to specific files, request parsing rules can be pre-designed in an embodiment of the present invention so that various situations of "web page file reading requests that do not point to specific files" can be completed through preset request parsing rules so that the completed web page file reading requests can point to specific files.
[0074] S103: Determine whether the protocol type of the current webpage file reading request is a file storage protocol;
[0075] Specifically, considering that when a user issues a web page file reading request through a client, different storage protocols may be adopted according to actual needs, for example, a file storage protocol may be adopted, or other types of storage protocols may be adopted, such as an object storage protocol, etc. Therefore, in order to meet requests for different storage protocols, in an embodiment of the present invention, after completing the web page file reading request, it can be determined whether the protocol type of the current web page file reading request is a file storage protocol, so as to trigger actions in subsequent steps according to the judgment result.
[0076] Among them, the file storage protocol and the object storage protocol can be of multiple types. For example, the file storage protocol can be a NAS (Network Attached Storage) protocol, and the object storage protocol can be an S3 (S3 Simple Storage Service) or Swift (Open Stack Object Storage) protocol, etc. The embodiment of the present invention does not limit this.
[0077] S104: If it is a file storage protocol, read a specific file from the distributed file storage system according to the webpage file reading request and feed the specific file back to the client;
[0078] Specifically, when the protocol type of the current web page file reading request is a file storage protocol, since it is applied to a distributed file storage system, the specific file can be directly read from the distributed file storage system according to the web page file reading request and the specific file can be fed back to the client.
[0079] Among them, the distributed file storage system has the characteristics of good scalability, low price and easy management by users.
[0080] S105: If it is not a file storage protocol, convert the protocol type of the web page file reading request into a file storage protocol, and execute the steps of reading a specific file from the distributed file storage system according to the web page file reading request and feeding the specific file back to the client.
[0081] Specifically, when the protocol type of the current web page file reading request is not a file storage protocol, in order to smoothly obtain the web page file from the distributed file storage system according to the web page file reading request, the protocol type of the web page file reading request can be converted into a file storage protocol, and the steps of reading the specific file from the distributed file storage system according to the web page file reading request and feeding the specific file back to the client are executed.
[0082] The present invention provides a static website hosting method. The present application can realize the static web page hosting function based on a distributed file storage system. First, it has the advantages of low cost and convenient expansion of the distributed file storage system. In the process of obtaining network content, even if it does not point to a specific file, the static website hosting method of the present application can also complete the web page file reading request according to the preset request parsing rules so that it points to a specific file, thereby improving the flexibility of using the static website. In addition, the static website hosting method of the present application can adapt to requests of multiple different types of protocols, so that users can obtain web page files through requests of multiple protocols, further improving the flexibility of using the static website.
[0083] Based on the above embodiment:
[0084] As a preferred embodiment, determining whether the webpage file reading request sent by the client points to a specific file is specifically as follows:
[0085] Determine whether the webpage file reading request sent by the client contains the name of a specific file;
[0086] If it is included, it is determined that the web page file reading request points to a specific file;
[0087] If not, it is determined that the web page file read request does not point to a specific file;
[0088] The web page file reading request is completed according to the preset request parsing rules so that it points to a specific file:
[0089] If the web page file reading request does not contain a specific file name, the index file path is obtained from the metadata;
[0090] The web page file read request is completed according to the index file path so that it points to the index file.
[0091] Specifically, under normal circumstances, if it points to a specific file, the web page file reading request will include the specific file name. Therefore, by judging whether the web page file reading request sent by the client contains the name of a specific file, it is possible to quickly and accurately judge whether the web page file reading request sent by the client points to a specific file. Specifically, if it contains the name of a specific file, it is determined that the web page file reading request points to a specific file; otherwise, it is determined that the web page file reading request does not point to a specific file. Considering that when the specific file name is not included, the user usually needs to access the index page of the website, that is, the main interface, in order to access the web page based on the index page, therefore, in an embodiment of the present invention, when the web page file reading request does not contain a specific file name, the index file path can be obtained from the metadata; the web page file reading request is completed according to the index file path so that it points to the index file. In this way, the client can generate an index page of the static website through the received index file, which is convenient for the user to further access the content in the static website.
[0092] As a preferred embodiment, after determining that the webpage file reading request points to a specific file, the static website hosting method further includes:
[0093] Determine whether a specific file exists in the directory provided by the web page file reading request;
[0094] If it does not exist, get the 404 error file path from the metadata;
[0095] The web page file read request is completed according to the 404 error file path so that it points to the 404 error file.
[0096] Specifically, considering that in some cases, although the web page file reading request provided by the client points to a specific file, due to directory errors or file name errors, the specific file specified may not exist under the target provided. Therefore, in an embodiment of the present invention, it can be determined whether there is a specific file under the directory provided by the web page file reading request; if it does not exist, the 404 error file path is obtained from the metadata; the web page file reading request is completed according to the 404 error file path so that it points to the 404 error file.
[0097] The client may generate a 404 error page of a webpage according to the received 404 error file so that the user can understand the error information.
[0098] As a preferred embodiment, determining whether the webpage file reading request sent by the client includes the name of a specific file is specifically as follows:
[0099] Upon receiving a webpage file reading request sent by a client, determining whether the source of the webpage file reading request is a subdomain;
[0100] If it is a subdomain, determine whether the web page file read request contains the name of a specific file.
[0101] Specifically, considering that the distributed storage system can host static web pages of specified subdomain names, the source of the web page file reading request sent by the client also needs to be the subdomain name of the static web page hosted by the distributed storage system. Therefore, in an embodiment of the present invention, when receiving the web page file reading request sent by the client, it can be determined whether the source of the web page file reading request is a subdomain name. If it is a subdomain name, it can be determined whether the web page file reading request contains the name of a specific file. If it is not a subdomain name, an error can also be reported.
[0102] As a preferred embodiment, if it is a subdomain, then determining whether the webpage file read request contains the name of a specific file is specifically as follows:
[0103] If it is a subdomain, determine whether the file directory that the web page file read request requests to access has enabled the static website hosting function;
[0104] If it is enabled, it is determined whether the web page file reading request contains the name of a specific file.
[0105] Specifically, considering that although the distributed storage system may host static web pages for a certain subdomain name, the static website hosting function of the file directory corresponding to the static web page can be set to be turned on / off on the distributed storage system, therefore, when determining that the source of the web page file reading request is a subdomain name, it is also possible to first determine whether the static website hosting function has been turned on for the file directory that the web page file reading request applies to access. If it is turned on, then determine whether the web page file reading request contains the name of a specific file.
[0106] Among them, if the file directory that the web page file read request applies to access does not have the static website hosting function enabled, then this situation can also be fed back to the client so that it can be aware of it.
[0107] As a preferred embodiment, after determining whether the file directory to which the webpage file reading request is to be accessed has the static website hosting function enabled, and before determining whether the webpage file reading request includes the name of a specific file, the static website hosting method further includes:
[0108] If it is enabled, determine whether there is an error in the web page file read request;
[0109] If it exists, then determine the error code of the web page file read request;
[0110] According to the preset correspondence between the error code and the error file path, determine the error file path corresponding to the error code;
[0111] Complete the web page file read request according to the error file path so that it points to the error file;
[0112] If it does not exist, execute the step of determining whether the web page file reading request contains the name of a specific file.
[0113] Specifically, considering that in addition to the situation where a specific file cannot be found in the specified directory, there may be many other types of errors in the web page file reading request. In the case of an error, it is obviously impossible to use it to obtain the web page file. Therefore, in an embodiment of the present invention, when it is determined that there is an error in the web page file reading request, the error code of the web page file reading request can be determined (one error code can correspond to one type of error), and the correspondence between the error code and the error file path is preset in the embodiment of the present invention. According to the preset correspondence between the error code and the error file path, the error file path corresponding to the error code can be determined, and then the web page file reading request is completed according to the error file path (the corresponding error file is stored under the error file path) so that it points to the error file. The client can generate a corresponding page based on the received error file to facilitate the user to know the specific type of error in the web page file reading request.
[0114] As a preferred embodiment, the static website hosting method further includes:
[0115] In response to the first update instruction, the correspondence between the preset error code and the error reporting file path is updated.
[0116] Specifically, considering that users may need to update the correspondence between preset error codes and error file paths in some cases, an update interface is provided in an embodiment of the present invention, and users can trigger the update action of the correspondence between preset error codes and error file paths by generating a first update instruction.
[0117] As a preferred embodiment, the protocol type of the web page file reading request is converted into the file storage protocol as follows:
[0118] Convert the protocol type of the web page file read request to the network attached storage NAS protocol.
[0119] Specifically, the NAS protocol has the advantages of strong reliability and simple rules.
[0120] Of course, in addition to the NAS protocol, the file storage protocol may also be of other types, which are not limited in the embodiment of the present invention.
[0121] As a preferred embodiment, after determining whether the webpage file reading request sent by the client includes the name of a specific file, and before determining whether the protocol type of the current webpage file reading request is a file storage protocol, the static website hosting method further includes:
[0122] If it is included, then determining whether the target keyword exists in the name of the specific file included in the web page file reading request;
[0123] If it exists, the target file corresponding to the target keyword is determined according to the preset correspondence between the keyword and the file;
[0124] Update the web page file read request according to the path of the target file.
[0125] Specifically, considering that there is often a phenomenon that the name of the specific file pointed to in the web page file reading request is incorrect, the specific file pointed to cannot be found correctly, and considering that there are usually some keywords in the name of the web page file, the complete name of the corresponding web page file can be determined by the keyword. Therefore, in an embodiment of the present invention, when it is determined that the web page file reading request sent by the client contains the name of the specific file, it can be determined whether there is a target keyword in the name of the specific file included in the web page file reading request. If so, the target file corresponding to the target keyword can be determined based on the preset correspondence between the keyword and the file, and then the web page file reading request can be updated according to the path of the target file. In this way, even if the name of the specific file contained in the web page file reading request sent by the client is incorrect, as long as there is no problem with the keyword, the present application can also automatically correct the specific web page file it wants to point to, which is beneficial to improving user experience.
[0126] As a preferred embodiment, the target file corresponding to the target keyword is determined according to the preset correspondence between the keyword and the file, specifically:
[0127] Determine the target file name corresponding to the target keyword based on the preset correspondence between the keyword and the file name;
[0128] Determine the target file corresponding to the target file name.
[0129] Specifically, in the embodiment of the present invention, the corresponding file name can be found through the keyword, and then the target file corresponding to the target file name can be determined. The file name can be corrected by constructing a simple correspondence between the keyword and the file name.
[0130] Specifically, it is worth mentioning that all files of a static web page corresponding to a subdomain name can be stored in a bucket (storage unit) of a distributed storage system. The bucket can contain multi-level directories. These web page files need to set public read permissions in order to read them, and the bucket can store relevant metadata, such as the index file path, 404 error file path and redirection rules. The redirection rules include the aforementioned "correspondence between the preset error code and the error file path" and "correspondence between the preset keyword and the file name", and the metadata can be stored in the first-level directory of the static web page, that is, the namespace.
[0131] As a preferred embodiment, the static website hosting method further includes:
[0132] In response to the second update instruction, the correspondence between the preset keywords and the file names is updated.
[0133] Specifically, considering that users may need to update the correspondence between preset keywords and file names in some cases, an update interface is provided in an embodiment of the present invention, and users can trigger the update action of the correspondence between preset keywords and file names by generating a second update instruction.
[0134] Please refer to Figure 2 , Figure 2 This is a schematic diagram of the structure of a static website hosting device provided by the present invention, which includes:
[0135] The first judgment module 21 is used to judge whether the webpage file reading request sent by the client points to a specific file, and if not, trigger the completion module 22;
[0136] A completion module 22 is used to complete the web page file reading request according to the preset request parsing rules so that it points to a specific file;
[0137] The second judgment module 23 is used to judge whether the protocol type of the current web page file reading request is a file storage protocol. If it is a file storage protocol, the reading module 24 is triggered; if it is not a file storage protocol, the conversion module 25 is triggered;
[0138] The reading module 24 is used to read a specific file from the distributed file storage system according to the web page file reading request and feed the specific file back to the client;
[0139] The conversion module 25 is used to convert the protocol type of the web page file reading request into a file storage protocol and trigger the reading module.
[0140] The present invention provides a static website hosting device. The present application can realize the static web page hosting function based on a distributed file storage system. First, it has the advantages of low cost and convenient expansion of the distributed file storage system. In the process of obtaining network content, even if it does not point to a specific file, the static website hosting method of the present application can also complete the web page file reading request according to the preset request parsing rules so that it points to a specific file, thereby improving the flexibility of using static websites. In addition, the static website hosting method of the present application can adapt to requests of multiple different types of protocols, so users can obtain web page files through requests of multiple protocols, further improving the flexibility of using static websites.
[0141] For an introduction to the static website hosting device provided by an embodiment of the present invention, please refer to the aforementioned embodiment of the static website hosting method, and the embodiment of the present invention will not be described in detail here.
[0142] Please refer to Figure 3 , Figure 3 This is a schematic diagram of the structure of a static website hosting device provided by the present invention, which includes:
[0143] Memory 31, for storing computer programs;
[0144] The processor 32 is configured to implement the steps of the static website hosting method in the aforementioned embodiment when executing the computer program.
[0145] The present invention provides a static website hosting device. The present application can realize the static web page hosting function based on a distributed file storage system. First, it has the advantages of low cost and convenient expansion of the distributed file storage system. In the process of obtaining network content, even if it does not point to a specific file, the static website hosting method of the present application can also complete the web page file reading request according to the preset request parsing rules so that it points to a specific file, thereby improving the flexibility of using static websites. In addition, the static website hosting method of the present application can adapt to requests of multiple different types of protocols, so users can obtain web page files through requests of multiple protocols, further improving the flexibility of using static websites.
[0146] For an introduction to the static website hosting device provided by an embodiment of the present invention, please refer to the aforementioned embodiment of the static website hosting method, and the embodiment of the present invention will not be described in detail here.
[0147] The present invention also provides a server, comprising a server body and the above-mentioned static website hosting device connected to the server body.
[0148] The present invention provides a server, which can realize the static web page hosting function based on a distributed file storage system. First, it has the advantages of low cost and convenient expansion of the distributed file storage system. In the process of obtaining network content, even if it does not point to a specific file, the static website hosting method of the present application can also complete the web page file reading request according to the preset request parsing rules so that it points to a specific file, thereby improving the flexibility of using static websites. In addition, the static website hosting method of the present application can adapt to requests of multiple different types of protocols, so users can obtain web page files through requests of multiple protocols, further improving the flexibility of using static websites.
[0149] For an introduction to the server provided in the embodiment of the present invention, please refer to the aforementioned embodiment of the static website hosting method, and the embodiment of the present invention will not be described in detail here.
[0150] Please refer to Figure 4 , Figure 4 This is a structural diagram of a computer-readable storage medium provided by the present invention. The computer-readable storage medium 40 stores a computer program 41. When the computer program 41 is executed by the processor 31, the steps of the static website hosting method in the above embodiment are implemented.
[0151] The present invention provides a computer-readable storage medium. The present application can realize the static web page hosting function based on a distributed file storage system. First, it has the advantages of low cost and convenient expansion of the distributed file storage system. In the process of obtaining network content, even if it does not point to a specific file, the static website hosting method of the present application can also complete the web page file reading request according to the preset request parsing rules so that it points to a specific file, thereby improving the flexibility of using static websites. In addition, the static website hosting method of the present application can adapt to requests of multiple different types of protocols, so that users can obtain web page files through requests of multiple protocols, further improving the flexibility of using static websites.
[0152] For an introduction to the computer-readable storage medium provided in an embodiment of the present invention, please refer to the aforementioned embodiment of the static website hosting method, and the embodiment of the present invention will not be described in detail here.
[0153] In this specification, the various embodiments are described in a progressive manner, with each embodiment focusing on the differences from the other embodiments. Similar or identical parts between the various embodiments may be referred to in conjunction with each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and for relevant parts, reference may be made to the method description. It should also be noted that, in this specification, relational terms such as first and second, etc., are used solely to distinguish one entity or operation from another, and do not necessarily require or imply any actual relationship or order between these entities or operations. Furthermore, the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, article, or device comprising that element.
[0154] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A static website hosting method, characterized in that: include: Determine whether the web page file read request sent by the client points to a specific file; If not, the webpage file reading request is completed according to the preset request parsing rules so that it points to a specific file; Determining whether the protocol type of the current webpage file reading request is a file storage protocol; If it is a file storage protocol, then reading the specific file from the distributed file storage system according to the webpage file reading request and feeding the specific file back to the client; If it is not a file storage protocol, converting the protocol type of the webpage file reading request into the file storage protocol, and executing the steps of reading the specific file from the distributed file storage system according to the webpage file reading request and feeding the specific file back to the client; The method of determining whether the webpage file reading request sent by the client points to a specific file is as follows: Determine whether the webpage file reading request sent by the client contains the name of a specific file; If it is included, it is determined that the web page file reading request points to a specific file; If not, it is determined that the webpage file reading request does not point to a specific file; After determining whether the webpage file reading request sent by the client includes the name of a specific file, and before determining whether the protocol type of the current webpage file reading request is a file storage protocol, the static website hosting method further includes: If it is included, then if there is an error in the name of the specific file, determining whether there is a target keyword in the name of the specific file included in the web page file reading request; If so, the target file corresponding to the target keyword is determined according to the preset correspondence between the keyword and the file; The web page file reading request is updated according to the path of the target file.
2. The static website hosting method according to claim 1, characterized in that: The webpage file reading request is completed according to the preset request parsing rules so that it points to a specific file: If the webpage file reading request does not include a specific file name, then obtaining the index file path from the metadata; The web page file read request is completed according to the index file path so that it points to the index file.
3. The static website hosting method according to claim 2, characterized in that: After determining that the webpage file reading request points to a specific file, the static website hosting method further includes: Determine whether the specific file exists in the directory provided in the webpage file reading request; If it does not exist, get the 404 error file path from the metadata; The web page file read request is completed according to the 404 error file path so that it points to the 404 error file.
4. The static website hosting method according to claim 3, characterized in that: The method of determining whether the webpage file reading request sent by the client contains the name of a specific file is as follows: Upon receiving a webpage file reading request sent by a client, determining whether the source of the webpage file reading request is a subdomain; If it is a subdomain, it is determined whether the web page file reading request includes the name of a specific file.
5. The static website hosting method according to claim 4, characterized in that: If it is a subdomain, then the determination of whether the webpage file read request contains the name of a specific file is as follows: If it is a subdomain, determine whether the file directory to which the webpage file reading request applies for access has enabled the static website hosting function; If it is enabled, it is determined whether the webpage file reading request includes the name of a specific file.
6. The static website hosting method according to claim 5, characterized in that: After determining whether the file directory accessed by the webpage file reading request has enabled the static website hosting function, and before determining whether the webpage file reading request includes the name of a specific file, the static website hosting method further includes: If it is enabled, determining whether there is an error in the webpage file reading request; If so, determining the error code of the webpage file reading request; According to the correspondence between the preset error code and the error file path, determine the error file path corresponding to the error code; Completing the webpage file reading request according to the error reporting file path so that it points to the error reporting file; If not, execute the step of determining whether the web page file reading request includes the name of a specific file.
7. The static website hosting method according to claim 6, characterized in that: This static website hosting method also includes: In response to the first update instruction, the correspondence between the preset error code and the error file path is updated.
8. The static website hosting method according to claim 1, wherein: The specific conversion of the protocol type of the webpage file reading request to the file storage protocol is: The protocol type of the webpage file reading request is converted into a Network Attached Storage (NAS) protocol.
9. The static website hosting method according to claim 1, wherein: The target file corresponding to the target keyword is determined based on the preset correspondence between the keyword and the file: Determining the target file name corresponding to the target keyword based on the preset correspondence between the keyword and the file name; Determine the target file corresponding to the target file name.
10. The static website hosting method according to claim 9, characterized in that: This static website hosting method also includes: In response to the second update instruction, the correspondence between the preset keywords and the file names is updated.
11. A static website hosting device, characterized in that: include: The first judgment module is used to judge whether the webpage file reading request sent by the client points to a specific file, and if not, trigger the completion module; The completion module is used to complete the webpage file reading request according to a preset request parsing rule so that it points to a specific file; a second determination module, configured to determine whether the protocol type of the current webpage file reading request is a file storage protocol, and if so, trigger the reading module; if not, trigger the conversion module; The reading module is configured to read the specific file from the distributed file storage system according to the webpage file reading request and feed the specific file back to the client; The conversion module is used to convert the protocol type of the webpage file reading request into the file storage protocol and trigger the reading module; The method of determining whether the webpage file reading request sent by the client points to a specific file is as follows: Determine whether the webpage file reading request sent by the client contains the name of a specific file; If it is included, it is determined that the web page file reading request points to a specific file; If not, it is determined that the webpage file reading request does not point to a specific file; After determining whether the webpage file reading request sent by the client includes the name of a specific file, and before determining whether the protocol type of the current webpage file reading request is a file storage protocol, the static website hosting method further includes: If it is included, then if there is an error in the name of the specific file, determining whether there is a target keyword in the name of the specific file included in the web page file reading request; If so, the target file corresponding to the target keyword is determined according to the preset correspondence between the keyword and the file; The web page file reading request is updated according to the path of the target file.
12. A static website hosting device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the static website hosting method according to any one of claims 1 to 10 when executing the computer program.
13. A server, characterized in that: The static website hosting device comprises a server body and the static website hosting device as claimed in claim 12 connected to the server body.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the static website hosting method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Management method for static hosting web site and management system
CN106021607A
Interface adaptation method, apparatus and system
CN109672732A
Data storage system supporting protocol intercommunication
CN114466083A