Website conversion and access control method and system
By generating unique short URL suffixes through hash processing and collision checking, and performing intelligent redirection based on user attributes, the technology solves the problems of large space consumption and insufficient redirection of long URLs in existing technologies, and achieves efficient and secure URL conversion and access control.
Patent Information
- Application Number
- CN202511165845.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2026-03-20
AI Technical Summary
Existing URL conversion methods cannot meet the needs of different clients accessing the same short URL and being redirected to different long URLs. They lack precise targeting, and long URLs occupy a lot of character space in scenarios such as SMS, increasing costs and affecting user experience.
The URL is hashed and encoded using a hash function (such as MurmurHash) to generate a short URL suffix. A Bloom filter and a cache database are used to check for collisions to ensure uniqueness. When accessing the URL, the system performs intelligent redirection based on user attributes and conditions.
It achieves efficient and unique generation of shortened URLs, supports precise targeted redirection for different users or under different conditions, improves user experience and network security, reduces costs, and enhances data analysis and security protection capabilities.
Smart Images

Figure CN121711325A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technology, and more specifically, to a URL conversion and access control method, a computer program product, and a URL conversion and access control system. Background Technology
[0002] With the rapid development of internet technology and the widespread adoption of mobile devices, push notification services have become a crucial bridge for communication between businesses and users. Push notifications often need to include links so users can directly access relevant content or services. However, long links (or long URLs) have significant drawbacks in scenarios like SMS, such as consuming large amounts of character space, leading to excessively long marketing content, increased SMS costs, and a negative impact on user experience. Therefore, converting long URLs to short URLs can not only shorten link length and reduce costs but also improve content delivery efficiency.
[0003] Existing solutions mainly focus on methods for generating shortened URLs. From a business perspective, they only meet the basic need to redirect to the target long URL via the shortened URL. They cannot meet the needs of different clients accessing the same short URL and being redirected to different long URLs. They lack technical methods for precise targeting, thus affecting the user experience. Summary of the Invention
[0004] According to one aspect of this application, a URL conversion and access control method is provided, the method comprising: hashing a first URL using a hash function and performing encoding conversion to generate a URL suffix, wherein the character length of the URL suffix is shorter than the character length of the first URL; checking whether the generated URL suffix conflicts with an existing URL suffix; and, if there is no conflict, combining the URL suffix with a base domain name to form a second URL, wherein the method further comprises: when a user accesses the second URL, selecting one of the configured URL targets for redirection based on the user's attribute information and / or access conditions, wherein the configured URL targets include the first URL.
[0005] As a supplement or replacement to the above scheme, in the above method, the hash function is the MurmurHash function, and the encoding is converted to base-62 or base-36 encoding.
[0006] As a supplement or replacement to the above scheme, in the above method, the URL suffix is a string of combined characters containing numbers and uppercase and lowercase letters, with a length of 6 to 32 characters.
[0007] As a supplement or replacement to the above scheme, in the above method, the process of hashing and encoding the first URL using a hash function to generate a URL suffix includes: hashing the first URL using the MurmurHash function to obtain a hash value; encoding the hash value in base-62 or base-36 to generate a string; and truncating and padding the generated string to generate the URL suffix.
[0008] As a supplement or replacement to the above scheme, in the above method, checking whether the generated URL suffix conflicts with the existing URL suffix includes: using a Bloom filter to determine whether the generated URL suffix already exists; and when the determination is "no", determining that the generated URL suffix does not conflict with the existing URL suffix.
[0009] As a supplement or replacement to the above solution, the method of checking whether the generated URL suffix conflicts with existing URL suffixes further includes: when the determination is "yes", querying the cache and database to see if the generated URL suffix exists; when the generated URL suffix does not exist in the cache and the database, determining that the generated URL suffix does not conflict with existing URL suffixes.
[0010] As a supplement or replacement to the above solution, in the above method, checking whether the generated URL suffix conflicts with the existing URL suffix also includes: when the generated URL suffix exists in the cache or the database, outputting information related to the URL suffix.
[0011] As a supplement or replacement to the above solution, in the above method, when there is no conflict, the URL suffix is recorded in the Bloom filter.
[0012] As a supplement or replacement to the above solution, in the above method, when there is no conflict, the URL suffix is also stored in the cache or database according to the hot and cold data separation strategy.
[0013] As a supplement or replacement to the above scheme, in the above method, the process of hashing and encoding the first URL using a hash function to generate a URL suffix includes: receiving the user identifier of each user; and combining the user identifier with the first URL as input, hashing and encoding the URL using the MurmurHash function to generate a URL suffix.
[0014] As a supplement or replacement to the above scheme, in the above method, using a hash function to hash the first URL and perform encoding conversion to generate a URL suffix includes: using the MurmurHash function to hash the first URL and perform encoding conversion to generate an initial URL suffix; and selecting a padding character from the base string according to the current date and the initial URL suffix, wherein the initial URL suffix and the padding character are combined to obtain the generated URL suffix.
[0015] As a supplement or replacement to the above scheme, in the above method, when querying the generated URL suffix, the generation date of the URL suffix is calculated based on the generated URL suffix, and the first URL corresponding to the URL suffix is read from the corresponding shard or table.
[0016] As a supplement or replacement to the above scheme, the above method also includes: adjusting the parameters of the hash function or adding additional information to regenerate the URL suffix when a conflict exists.
[0017] As a supplement or replacement to the above scheme, in the above method, the user's attribute information includes user ID, user geographical location, user device type, or user behavior data.
[0018] As a supplement or replacement to the above scheme, the access conditions in the above method include access time, access frequency, access source or network environment.
[0019] As a supplement or replacement to the above solution, the above method also includes: recording the user's access behavior when the user accesses the second URL, for subsequent data analysis and access strategy optimization.
[0020] As a supplement or replacement to the above solution, the above method also includes: using an access security model to control access to the second URL, wherein the access security model is established based at least on the access IP, access device, access source, and access frequency per unit time.
[0021] As a supplement or replacement to the above solution, the above method also includes: periodically checking whether the first URL is in the malicious website database; and / or periodically crawling the web page content corresponding to the first URL, and calling the risk control system to determine whether the web page content is safe.
[0022] According to another aspect of this application, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described above.
[0023] According to another aspect of this application, a URL conversion and access control system is provided, the system comprising: a URL generation device for generating a second URL based on a first URL; and a URL access device for controlling access when a user accesses the second URL; wherein the URL generation device is configured to: hash the first URL using a hash function and perform encoding conversion to generate a URL suffix, wherein the character length of the URL suffix is shorter than the character length of the first URL; check whether the generated URL suffix conflicts with an existing URL suffix; and if there is no conflict, combine the URL suffix with a base domain name to form a second URL; and wherein the URL access device is configured to, when a user accesses the second URL, select one of the configured URL targets for redirection based on the user's attribute information and / or access conditions, the configured URL target including the first URL.
[0024] As a supplement or replacement to the above solution, in the above system, the URL generation device is configured to: hash the first URL using the MurmurHash function to obtain a hash value; encode the hash value in base-62 or base-36 to generate a string; and truncate and padded the generated string to generate the URL suffix.
[0025] As a supplement or replacement to the above solution, in the above system, the URL generation device is configured to: use a Bloom filter to determine whether the generated URL suffix already exists; and when the determination is "no", determine that the generated URL suffix does not conflict with the existing URL suffix.
[0026] As a supplement or replacement to the above solution, in the above system, the URL generation device is further configured to: when the determination is "yes", query the cache and the database to see if the generated URL suffix exists; and when the generated URL suffix does not exist in the cache and the database, determine that the generated URL suffix does not conflict with the existing URL suffix.
[0027] As a supplement or replacement to the above solution, in the above system, the URL generation device is further configured to output information related to the URL suffix when the generated URL suffix exists in the cache or the database.
[0028] As a supplement or replacement to the above solution, in the above system, the URL generation device is further configured to: record the URL suffix in a Bloom filter when there is no conflict, and store the URL suffix in a cache or database respectively according to a hot and cold data separation strategy.
[0029] As a supplement or replacement to the above scheme, in the above system, the URL generation device is configured to: receive the user identifier of each user; and combine the user identifier with the first URL as input, perform hash processing using the MurmurHash function and perform encoding conversion, thereby generating a URL suffix.
[0030] As a supplement or replacement to the above scheme, in the above system, the URL generation device is configured to: hash the first URL using the MurmurHash function and perform encoding conversion to generate an initial URL suffix; and select a padding character from the base string according to the current date and the initial URL suffix, wherein the initial URL suffix and the padding character are combined to obtain the generated URL suffix.
[0031] As a supplement or replacement to the above solution, in the above system, the URL generation device is further configured to: adjust the parameters of the hash function or add additional information to regenerate the URL suffix when a conflict exists.
[0032] As a supplement or replacement to the above solution, the system further includes: an access analysis device, used to record the user's access behavior when the user accesses the second URL, and to perform data analysis and access strategy optimization.
[0033] As a supplement or replacement to the above solution, in the above system, the website access device is configured to: control access to the second website using an access security model, wherein the access security model is established based at least on the access IP, access device, access source, and access frequency per unit time.
[0034] As a supplement or replacement to the above solution, the system further includes: an access security device for periodically checking whether the first URL is in a malicious website database; and / or periodically crawling the web page content corresponding to the first URL and calling the risk control system to determine whether the web page content is safe.
[0035] The URL conversion and access control scheme of this application solves the problem of low efficiency in short URL generation by using a hash function (e.g., MurmurHash function) to hash and encode a first URL (e.g., a long URL) to generate a URL suffix (e.g., a short URL suffix). Simultaneously, by checking whether the generated URL suffix (e.g., the short URL suffix) conflicts with existing URL suffixes, duplicate generation of short URLs is avoided, ensuring the uniqueness of short URLs. Furthermore, the URL conversion and access control scheme of this application also includes a function that, when a user accesses a second URL (e.g., a short URL), selects a target URL from the configured URLs for redirection based on the user's attribute information and / or access conditions. This achieves intelligent redirection, meets the need to redirect to different long URLs when accessing the same short URL, and provides precise targeting services.
[0036] In one embodiment, the URL shortening and access control scheme of this application, in addition to basic URL shortening functionality, also includes recording the user's access behavior when visiting a second URL. This facilitates subsequent data analysis and access strategy optimization. This scheme can collect user clicks, page visits, and other behavioral data in real time, enabling fine-grained analysis of user behavior, identifying specific behavioral patterns and preferences, and helping to optimize product design and user experience. This fine-grained analysis allows businesses to more effectively optimize their products and services, significantly improving user satisfaction.
[0037] Furthermore, the URL translation and access control scheme of this application also utilizes an access security model to manage access to the second URL. This model is established based at least on the accessing IP, accessing device, access source, and access frequency per unit time. Such an access security model can intelligently identify attackers, automatically lock the IP address that initiates the attack by connecting to the website, prohibit access to the attacked website, and add the attacker to the network blacklist. In this way, the URL translation and access control scheme of this application improves the reliability of the access security model, enhances the efficiency of the entire system's security analysis and detection, and improves the overall network security protection capability. Attached Figure Description
[0038] The above and other objects and advantages of this application will become more fully clear from the following detailed description taken in conjunction with the accompanying drawings, wherein the same or similar elements are denoted by the same reference numerals.
[0039] Figure 1 A flowchart illustrating an embodiment of the URL translation and access control method according to this application is shown.
[0040] Figure 2 This illustration shows a flowchart of URL suffix generation according to an embodiment of this application;
[0041] Figure 3 A logical diagram illustrating a URL suffix conflict check according to an embodiment of this application is shown.
[0042] Figure 4 A schematic diagram of a URL suffix padding algorithm according to an embodiment of this application is shown; and
[0043] Figure 5 A schematic diagram of the structure of a URL translation and access control system according to an embodiment of this application is shown. Detailed Implementation
[0044] In the following, URL translation and access control schemes according to various exemplary embodiments of this application will be described in detail with reference to the accompanying drawings.
[0045] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the embodiments of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples, without contradiction.
[0046] Figure 1 A flowchart illustrating a URL translation and access control method 1000 according to an embodiment of this application is shown. Figure 1 As shown, the method 1000 includes the following steps:
[0047] In step S110, a hash function is used to hash the first URL (e.g., a long URL) and perform encoding conversion to generate a URL suffix (e.g., a short URL suffix), wherein the character length of the URL suffix is shorter than the character length of the first URL.
[0048] In step S120, it is checked whether the generated URL suffix conflicts with existing URL suffixes; and
[0049] In step S130, when there is no conflict, the URL suffix is combined with the base domain name to form a second URL (e.g., a short URL). The method 1000 further includes: when a user accesses the second URL (e.g., the short URL), a user is redirected from a configured URL target based on the user's attribute information and / or access conditions. The configured URL target includes the first URL.
[0050] In the context of this application, the term "hash function" is an algorithm that transforms an input (e.g., a long URL) into a fixed-size output (e.g., a hash value or hash code). This transformation is one-way; that is, mapping from the original data to the hash value is easy, but reversing the hash value to derive the original data is very difficult.
[0051] In step S110, a hash function is used to hash the first URL (e.g., a long URL) and perform encoding conversion to generate a URL suffix (e.g., a short URL suffix), wherein the character length of the URL suffix is shorter than the character length of the first URL. The purpose of step S110 is to convert a long original URL (i.e., the first URL) into a shorter URL suffix.
[0052] In one embodiment, a hash function (such as MurmurHash) is used to process the original URL. A hash function can convert input data of arbitrary length into a fixed-length output (hash value), and the output hash value is typically different for different inputs. The hash value generated by the hash function is then converted into a readable character sequence using a specific encoding method. In one embodiment, the encoding conversion method includes base-62 encoding (using 62 characters: 0-9, az, AZ) or base-36 encoding (using 36 characters: 0-9, az). This encoding conversion not only makes the hash value easier to read and share, but also allows the length of the URL suffix to be adjusted as needed.
[0053] It is understandable that in the above embodiments, the encoded string is the URL suffix, and its length is usually much shorter than the original URL. This suffix is a major component of the short URL, used to combine with the base domain to form a complete short URL. For example, assuming there is a short URL service provider with the base domain shorturl.com, then the short URL generated by this service might be:
[0054] (1) http: / / shorturl.com / abc123; or
[0055] (2) http: / / shorturl.com / xyz789.
[0056] In the example above, shorturl.com is the base domain, while abc123 and xyz789 are the URL suffixes generated through hashing and encoding conversion, respectively.
[0057] The URL suffix should be significantly shorter than the original URL. In one embodiment, the URL suffix is a string of numbers and uppercase and lowercase letters, with a length of 6 to 32 characters. For example, using the MurmurHash hash function, after base-62 or base-36 conversion, it can support short URL suffixes of 6 to 32 characters, ensuring consistent output when the input is consistent.
[0058] The "MurmurHash hash function" is a non-cryptographic hash algorithm widely used for its high efficiency and low collision rate. This algorithm is based on a hybrid function design, dividing the input data into several segments and applying a non-linear function to each segment, then merging the results into a final hash value.
[0059] In one embodiment, step S110 includes: hashing the first URL using the MurmurHash function to obtain a hash value; encoding the hash value in base-62 or base-36 to generate a string; and truncating and padding the generated string to generate the URL suffix. In the above embodiment, the generated encoded string is truncated and padded to ensure that the generated URL suffix meets the predetermined length requirement. If the generated string is too long, a portion of the string can be truncated; if it is too short, specific characters can be added to pad the length. This step ensures that the generated URL suffix meets the length requirement while maintaining a certain degree of randomness and uniqueness.
[0060] In one embodiment, each user identifier (e.g., user ID) is used as a parameter in the hash calculation to generate the URL suffix. This ensures that each user receives a unique second URL. In one embodiment, step S110 includes: receiving each user's user identifier; and combining the user identifier with the first URL as input, performing hash processing using the MurmurHash function, and encoding conversion to generate the URL suffix. In this embodiment, by incorporating the user identifier (e.g., user ID) into the URL suffix generation process, we ensure that each user receives a unique second URL (e.g., a short URL). This method not only improves the personalization level of the URL conversion service but also helps meet the "one URL for one user" requirement.
[0061] Furthermore, in the above embodiments, combining the user identifier with the original long URL (first URL) can be achieved through simple concatenation, or a more complex structure can be used, such as appending the user ID as a query parameter to the long URL. This application does not limit this approach.
[0062] In one embodiment, to facilitate subsequent storage and / or querying (e.g., sharding and table partitioning), the generated URL suffix includes the date on which the URL suffix was generated. Specifically, step S110 includes: hashing and encoding the first URL using the MurmurHash function to generate an initial URL suffix; and selecting a padding character from the base string based on the current date and the initial URL suffix, wherein the initial URL suffix and the padding character are combined to obtain the generated URL suffix.
[0063] refer to Figure 4 It illustrates a schematic diagram of a URL suffix padding algorithm according to an embodiment of this application. Figure 4 As shown, the base string is a string consisting of numbers and uppercase and lowercase letters (e.g., 62 characters long with no repeated characters), used to generate the URL suffix. Assume the initial URL suffix obtained through the MurmurHash function and encoding conversion is Wk1234 (6 characters). Therefore, an additional 2 bits are needed to determine the current date. By combining the initial URL suffix and the padding characters, the final generated URL suffix is obtained.
[0064] In one embodiment, assuming the current date is July 4th, subtracting 7 (the current month) from the index of "W" in the base string yields the character "a"; similarly, subtracting 4 (the current day) from the index of "k" in the base string yields the character "1". Thus, the final generated URL suffix (i.e., the padded URL suffix) is Wk1234a1.
[0065] In other words, such as Figure 4 As shown, the month can be determined by subtracting the index of the 7th character (the second-to-last character "a") in the base string from the index of the 1st character ("W") in the URL suffix. Similarly, the day can be determined by subtracting the index of the 8th character ("1") in the base string from the index of the 2nd character ("k") in the URL suffix.
[0066] For example, when querying the URL suffix Wk1234a1, the same algorithm can be used to reverse-calculate the generation date as July 4th. This allows data such as the original URL corresponding to the URL suffix to be retrieved from the relevant shards and tables when needed.
[0067] Of course, those skilled in the art can consider other schemes to select the padding character from the base string based on both the current date and the initial URL suffix. For example, the index of the first character of the URL suffix in the base string minus the index of the seventh character of the URL suffix in the base string can be used to determine the specific day (instead of the month), while the index of the second character of the URL suffix in the base string minus the index of the eighth character of the URL suffix in the base string can be used to determine the month (instead of the specific day).
[0068] After generating the URL suffix, it is necessary to further check whether the suffix already exists. As described in step S120, check whether the generated URL suffix conflicts with an existing URL suffix. In one embodiment, step S120 includes: using a Bloom filter to determine whether the generated URL suffix already exists; and if the determination is "no", determining that the generated URL suffix does not conflict with an existing URL suffix.
[0069] A Bloom filter is an efficient probabilistic data structure used in this embodiment to quickly determine whether a newly generated URL suffix might already exist in an existing set of URL suffixes. If the Bloom filter returns "No," meaning it considers the generated URL suffix to be nonexistent, then it can be determined that the generated URL suffix does not conflict with existing URL suffixes. Due to the characteristics of Bloom filters, they may produce false positives (i.e., incorrectly identifying a nonexistent element as existing), but they will not miss any (i.e., they will not incorrectly identify an existing element as nonexistent). Therefore, when the Bloom filter returns "No," we can be certain that the URL suffix is unique.
[0070] If the Bloom filter returns "yes," indicating that the URL suffix may exist, it is necessary to further check the cache and database to confirm whether a conflict actually exists. In one embodiment, step S120 further includes: when the determination is "yes," querying the cache and database to see if the generated URL suffix exists; if the generated URL suffix does not exist in either the cache or the database, determining that the generated URL suffix does not conflict with existing URL suffixes. In one embodiment, step S120 further includes: when the generated URL suffix exists in the cache or the database, outputting information related to the URL suffix (e.g., the original URL corresponding to the URL suffix).
[0071] Figure 3 A logical diagram illustrating a URL suffix conflict check according to one embodiment of this application is shown. Figure 3As shown, the method determines whether a URL suffix conflicts or already exists in three levels: First, it checks if the same URL suffix already exists in the Bloom filter (a characteristic of Bloom filters is that they may incorrectly determine a non-existent element as "existent," but they will never determine an existing element as "non-existent." Therefore, if the Bloom filter determines it as false (no, i.e., "non-existent"), then there is definitely no conflict). If the Bloom filter determines it as "existent," then it may not exist, and it needs to be further checked in the cache. If it exists in the cache, the long URL data corresponding to the existing URL suffix is directly returned. If it does not exist in the cache either, it needs to be checked in the database. If it exists, the relevant information about the existing URL suffix is output; if it does not exist, the final output result is "non-existent" or "no conflict." Through these three levels of judgment, it is ensured that the output is consistent when the input is consistent, and inconsistent when the input is inconsistent.
[0072] In one embodiment, when no conflicts exist, the URL suffix is recorded in the Bloom filter. That is, new URL suffixes are recorded in the Bloom filter to facilitate subsequent conflict checking. Using Bloom filters for conflict checking offers advantages such as improved query efficiency, reduced storage requirements (Bloom filters occupy less space compared to storing a complete list of all URL suffixes), and ease of scalability.
[0073] In one embodiment, when there is no conflict, the URL suffix is also stored in the cache or database respectively according to a hot and cold data separation strategy. That is, based on the popularity (access frequency) of the URL suffix (data), the data is divided into hot data and cold data, with hot data stored in the cache for fast access, and cold data stored in the database for long-term storage and infrequently accessed data.
[0074] In one embodiment, different hot and cold data separation strategies can be adopted based on cache space availability. For example, when cache space is sufficient, a "count-expiration time" strategy can be implemented: the lifespan of data in the cache is determined by the number of accesses (after the data's lifespan is exceeded, it is removed from the cache and stored in the database). For instance, the default initial expiration time for new data (such as a stored URL suffix) is 12 hours, and different expiration time extension strategies are applied based on access frequency. For example, if a URL suffix is accessed once, its expiration time increases by 1 hour (+1h); if it is accessed twice, the expiration time increases by 2 hours (+2h); if it is accessed three times, the expiration time increases by 3 hours (+3h); and so on, with the maximum expiration time not exceeding 720 hours. In other words, when cache space is sufficient, an expiration strategy algorithm is used to reflect the popularity of data through counting; the more accesses, the more the expiration time increases until the expiration time reaches a threshold (e.g., 720 hours).
[0075] When cache space is insufficient, an LRU (Least Recently Used) eviction policy can be used to remove the least recently accessed data from the cache (and store this data in the database). In other words, when cache space is insufficient, priority is determined based on the data's most recent access time (short-term popularity), and the least recently accessed data is evicted. Data that eventually reaches high access frequency is always stored in the cache, while cold data is stored in a traditional database or a large database.
[0076] In step S130, when there is no conflict, the URL suffix is combined with the base domain name to form a second URL (e.g., a short URL). The method 1000 further includes: when a user accesses the second URL (e.g., the short URL), a redirect is performed from a configured set of URL targets based on the user's attribute information and / or access conditions. The configured URL targets include the first URL. In other words, when it is confirmed that the generated URL suffix does not conflict, the suffix will be combined with the base domain name to form a second URL, commonly referred to as a short URL. For example, if the base domain name is short.url and the generated URL suffix is abc123, then the combined second URL (short URL) will be http: / / short.url / abc123. Subsequently, the mapping relationship between the original URL (long URL) and the newly generated URL suffix or the second URL (short URL) can be stored in a cache or database to ensure correct redirection when a user accesses the short URL. In one embodiment, when a user accesses a second URL (shortened URL), they can be redirected from a pre-configured pool of multiple URLs based on their attribute information (such as user ID, geographic location, device type, user behavior data, etc.) and access conditions (such as access time, access frequency, etc.). Thus, unlike the traditional one-to-one long and short URL system, this embodiment supports redirection to different long URLs based on user attribute information (such as user ID, geographic location, device type, etc.) and / or access conditions (such as access time, access frequency, access source, network environment, etc.). It also allows for control over access to short URLs to meet specific business needs and to counter malicious access.
[0077] In one embodiment, an access rule model can be established based on user request parameters (such as IP address, User-Agent, time, device type, access source, access region, etc.). An example of the model rule parameters is as follows:
[0078] Rule elements Rules and conditions Rule model results Access time 20:00-23:59 Long URL A1 Access device iOS system devices Long URL A2 Visiting areas Shanghai Long URL A3 Access Source test.com Long URL A4 none other Original long URL
[0079] In the example above, the configured URL targets include not only the original long URL (i.e., the first URL), but also four other different long URLs: long URL A1, long URL A2, long URL A3, and long URL A4. In other words, a short URL can point to multiple long URLs. Specifically, when a user opens the short URL between 20:00 and 23:59, they are directly redirected to long URL A1; otherwise, other model parameters are evaluated. If the user's access device is an Apple mobile phone, they are directly redirected to long URL A2; otherwise, the user's current access region is evaluated. If it is Shanghai, they are directly redirected to long URL A3; otherwise, the access source is evaluated. If the domain name of the access source is test.com, they are directly redirected to long URL A4; otherwise, they are redirected to the original long URL. It should be noted that the solution in this application is not limited to the specific example above. For example, the actual access strategy can have more branches to achieve more redirection targets.
[0080] Additionally, it should be noted that in the aforementioned embodiments, User-Agent refers to a field in the HTTP request header used to indicate the client information that initiated the request. The origin (source page) refers to a field in the HTTP request header used to indicate which page the current request originated from.
[0081] In one embodiment, although Figure 1 As not shown in the diagram, the above method 1000 may further include: recording the user's access behavior and redirection information when the user accesses the second URL (shortened URL) for subsequent data analysis and access strategy optimization. This data can help improve service quality, provide a personalized user experience, and optimize marketing effectiveness.
[0082] In one embodiment, the method 1000 may further include: using an access security model to control access to a second URL, wherein the access security model is established based at least on the access IP, access device, access source, and access frequency per unit time.
[0083] For example, a method class similar to the access rule model can be used to build an access security model, thereby controlling access to a second URL. An example of the model rule parameters is as follows:
[0084]
[0085]
[0086] In the example above, if the access security model is triggered, the access will be blocked. The access security model in this example has four layers of protection: The first layer checks if the accessing IP is in the IP blacklist; if so, it is blocked directly, and no further redirection is performed, but an error page is returned. The second layer checks the user agent in the request; if it is an insecure device or contains obvious crawler / scraping tool names, it is blocked directly. The third layer checks the frequency of the same request within a short period; for example, if the same request is made 5 times within 1 second, it indicates possible malicious access using tools, and it is blocked directly. The fourth layer checks if the source page of the accessed request is in the malicious domain database; if so, it is blocked directly. After all security checks pass, the subsequent redirection can be performed safely.
[0087] It should be noted that the access security model described above is merely an example and not a limitation. Real-world access security models may have more or fewer layers of protection; for example, machine learning models can be introduced to analyze user behavior and identify abnormal access patterns, such as unusual access paths or behavioral patterns. This behavioral analysis can help identify potential malicious users or automated attacks.
[0088] Through this multi-layered, comprehensive access security model, (short) URL services can ensure a secure user experience while providing convenient services.
[0089] In one embodiment, if a conflict is found in step S120, i.e., the generated URL suffix conflicts with an existing URL suffix (e.g., different original URLs generated the same URL suffix), additional measures are needed to resolve the conflict, such as regenerating the URL suffix or adding additional information (e.g., timestamp, user ID, etc.) to the URL suffix. In one embodiment, the URL suffix can be regenerated (e.g., by adjusting the parameters of the hash function or adding additional information during hash processing to regenerate the URL suffix), and the checking step can be re-executed until no conflict occurs.
[0090] In one embodiment, the method 1000 may further include: periodically checking whether the first URL (long URL) is in a malicious website database; and / or periodically crawling the webpage content corresponding to the first URL, and calling a risk control system to determine whether the webpage content is safe (e.g., whether it involves sensitive words, drug-related content, pornography, etc.). If the long URL is no longer safe, the corresponding short URL is marked with a risk flag, and subsequent requests for the short URL will no longer redirect.
[0091] Figure 2 A schematic diagram illustrating a process for generating a URL suffix (and subsequently a second URL) according to an embodiment of this application is shown. Figure 2As shown, in step 210, the original URL (long URL) is processed using the MurmurHash function and converted (in hexadecimal or base-62 encoding). Next, in step 220, the conversion result is truncated and padded. Subsequently, in step 230, a string of characters containing numbers and (upper) and lowercase letters is obtained, which is the initial short URL suffix. In step 240, a conflict check is performed on the initial URL suffix (e.g., checking if a matching long URL already exists). If a conflict is found, conflict resolution is performed in step 240 (e.g., adding fixed parameters), and then the process returns to step 210 to regenerate the URL suffix. This process continues until a conflict-free URL suffix is obtained or the loop terminates after a fixed number of iterations. If no conflict exists, in step 250, the URL suffix is separated into hot and cold data, and the URL suffix is output to finally form the second URL (short URL).
[0092] Those skilled in the art will readily understand that the URL conversion and access control methods (e.g., URL conversion and access control method 1000) provided in one or more embodiments of this application can be implemented by a computer program. For example, the computer program is included in a computer program product, and when executed by a processor, it implements the URL conversion and access control methods of one or more embodiments of this application. As another example, when a computer-readable storage medium (e.g., a USB flash drive) containing the computer program is connected to a computer, running the computer program executes the URL conversion and access control methods of one or more embodiments of this application.
[0093] refer to Figure 5 It illustrates a structural schematic diagram of a URL translation and access control system 5000 according to an embodiment of this application. Figure 5 As shown, the URL conversion and access control system 5000 includes a URL generation device 510, a URL access device 520, an access analysis device 530, and an access security device 540.
[0094] exist Figure 5In this embodiment, the URL generation device 510 is used to generate a second URL (short URL) based on a first URL (long URL); the URL access device 520 is used to control access to the second URL (short URL) by a user. Specifically, the URL generation device 510 is configured to: hash the first URL using a hash function and perform encoding conversion to generate a URL suffix, wherein the character length of the URL suffix is shorter than the character length of the first URL; check whether the generated URL suffix conflicts with existing URL suffixes; and if there is no conflict, combine the URL suffix with the base domain name to form the second URL. The URL access device 520 is configured to, when a user accesses the second URL, select one of the configured URL targets for redirection based on the user's attribute information and / or access conditions, wherein the configured URL targets include the first URL. The access analysis device 530 is configured to, when a user accesses the second URL, record the user's access behavior and perform data analysis and access strategy optimization. Access security device 540 is configured to periodically check whether the first URL is in the malicious website database; and / or periodically crawl the web page content corresponding to the first URL, and call the risk control system to determine whether the web page content is safe.
[0095] In one or more embodiments, the URL generation device 510 possesses a unique and flexible short URL generation strategy. Specifically, the URL generation device 510 is configured to use the MurmurHash hash function, which, after conversion from base-62 or base-36, can support short URL suffix characters of 6 to 32 characters, ensuring consistent input and output. It also incorporates deduplication and conflict handling mechanisms to ensure inconsistent output even with inconsistent input.
[0096] In one or more embodiments, the URL generation device 510 also supports a "personalized URL for each user" effect. Specifically, for the same long URL, the URL generation device 510 adds user parameters during the hash processing stage to generate a unique URL suffix and subsequently a short URL. This facilitates the (access analysis device 530) tracking of each user's behavior, achieving precise push notifications and feedback. In one or more embodiments, the URL generation device 510 is also configured to hide the date in the URL suffix according to a padding algorithm. This not only marks the generation date of the short URL but also enables sharding and table partitioning, easily supporting data storage of hundreds of millions of records and fast retrieval.
[0097] In one embodiment, the URL generation device 510 is configured to: hash a first URL using the MurmurHash function to obtain a hash value; encode the hash value in base-62 or base-36 to generate a string; and truncate and padded the generated string to generate the URL suffix.
[0098] In one embodiment, the URL generation device 510 is configured to: use a Bloom filter to determine whether the generated URL suffix already exists; and if the determination is "no", determine that the generated URL suffix does not conflict with existing URL suffixes. In another embodiment, the URL generation device 510 is further configured to: if the determination is "yes", query a cache and a database to see if the generated URL suffix exists; and if the generated URL suffix does not exist in either the cache or the database, determine that the generated URL suffix does not conflict with existing URL suffixes. In yet another embodiment, the URL generation device 510 is further configured to: if the generated URL suffix exists in the cache or the database, output information related to the URL suffix.
[0099] In one embodiment, the URL generation device 510 is configured to: record the URL suffix in a Bloom filter when there is no conflict, and store the URL suffix in a cache or a database respectively according to a hot and cold data separation strategy.
[0100] In one embodiment, the URL generation device 510 is configured to: receive a user identifier for each user; and combine the user identifier with the first URL as input, perform hash processing using the MurmurHash function, and perform encoding conversion to generate a URL suffix. In this way, the generated URL suffix can implicitly contain user information as needed, achieving a personalized URL for each user.
[0101] In one embodiment, the URL generation device 510 is configured to: hash and encode a first URL using the MurmurHash function to generate an initial URL suffix; and select a padding character from a base string based on the current date and the initial URL suffix, wherein the initial URL suffix and the padding character are combined to obtain the generated URL suffix. In this way, the generated URL suffix can implicitly include the date as needed, achieving the effect of supporting hundreds of millions of data points.
[0102] In one embodiment, the URL generation device 510 is further configured to adjust the parameters of the hash function or add additional information to regenerate the URL suffix when a conflict exists. This facilitates the generation of unique URL suffixes.
[0103] In one or more embodiments, the URL access device 520 is configured to control user access to a second URL (shortened URL) using a redirection rule model and a security rule model. For example, the URL access device 520 is configured to establish a redirection rule model based on IP address, user agent, time, device type, and referrer, analyze user requests, and redirect to a specified target page according to the matching rules, achieving targeted push notifications. As another example, the URL access device 520 is configured to establish a security rule model and decide whether to reject user requests based on whether security rules are matched.
[0104] In one or more embodiments, the access security device 540 is configured to crawl the content of the long URL page during the process of generating a short URL from a long URL, call the content risk control system, and check whether the long URL is safe.
[0105] In summary, the URL conversion and access control scheme of this application achieves precise redirection of the shortened URL to the target URL based on the analysis and matching of client information and combined with redirection rules, mainly reflected in the following aspects:
[0106] (1) Convert the first URL (long URL) to the second URL (short URL): Supports generating URL suffixes of 6 to 32 characters. It ensures that if the input is consistent, the output will be consistent, and if the input is inconsistent, the output will be inconsistent. It also supports one short URL corresponding to multiple long URLs.
[0107] (2) Different users have different characteristics such as location, device, access time and user tags. When they access the same short URL, they are redirected to the long URL corresponding to the hit model rule, thus achieving the purpose of targeted redirection.
[0108] (3) Supports “one thousand links per user”: For the same long URL, a unique short URL is generated for each user based on different user attributes, accurately pushing and tracking each user’s click behavior;
[0109] (4) Identification of false requests and risky content: to prevent malicious access from interfering with access effect analysis and occupying access system resources, and to protect users from accessing unsafe websites.
[0110] The above examples primarily illustrate the URL conversion and access control schemes of embodiments of this application. Although only some implementations of this application have been described, those skilled in the art should understand that this application can be implemented in many other forms without departing from its spirit and scope. Therefore, the examples and implementations shown are considered illustrative rather than restrictive, and this application may cover various modifications and substitutions without departing from the spirit and scope of this application as defined in the claims.
Claims
1. A URL conversion and access control method, characterized in that, The method includes: The first URL is hashed using a hash function and then encoded to generate a URL suffix, wherein the character length of the URL suffix is shorter than the character length of the first URL. Check if the generated URL suffix conflicts with existing URL suffixes; and When there is no conflict, the URL suffix is combined with the base domain name to form a second URL. The method further includes: when a user accesses the second URL, selecting one of the configured URL targets for redirection based on the user's attribute information and / or access conditions, wherein the configured URL targets include the first URL.
2. The method as described in claim 1, wherein, The hash function is the MurmurHash function, and the encoding is converted to base-62 or base-36 encoding.
3. The method as described in claim 1, wherein, The URL suffix is a string of numbers and uppercase and lowercase letters, with a length of 6 to 32 characters.
4. The method as described in claim 1 or 2, wherein, The first URL is hashed using a hash function and then encoded to generate URL suffixes including: The first URL is hashed using the MurmurHash function to obtain a hash value; The hash value is encoded in base-62 or base-36 to generate a string; and The generated string is truncated and padded to produce the URL suffix.
5. The method of claim 1, wherein, Checking whether the generated URL suffix conflicts with existing URL suffixes includes: Use a Bloom filter to determine if the generated URL suffix already exists; and If the result is "no", it is determined that the generated URL suffix does not conflict with existing URL suffixes.
6. The method of claim 5, wherein, Checking whether the generated URL suffix conflicts with existing URL suffixes also includes: If the result is "yes", check the cache and database to see if the generated URL suffix exists. If the generated URL suffix does not exist in either the cache or the database, it is determined that the generated URL suffix does not conflict with existing URL suffixes.
7. The method of claim 6, wherein, Checking whether the generated URL suffix conflicts with existing URL suffixes also includes: If the generated URL suffix exists in the cache or the database, output information related to the URL suffix.
8. The method of claim 1, wherein, When there is no conflict, the URL suffix is recorded in the Bloom filter.
9. The method of claim 8, wherein, When there is no conflict, the URL suffix will be stored in the cache or database respectively according to the hot and cold data separation strategy.
10. The method of claim 1, wherein, The first URL is hashed using a hash function and then encoded to generate URL suffixes including: Receive each user's user ID; and The user identifier is combined with the first URL as input, and the MurmurHash function is used to perform hash processing and encoding conversion to generate the URL suffix.
11. The method of claim 1, wherein, The first URL is hashed using a hash function and then encoded to generate URL suffixes including: The MurmurHash function is used to hash and encode the first URL to generate the initial URL suffix; and Based on the current date and the initial URL suffix, a padding character is selected from the base string, wherein the initial URL suffix and the padding character are combined to obtain the generated URL suffix.
12. The method of claim 11, wherein, When querying the generated URL suffix, the generation date of the URL suffix is calculated based on the generated URL suffix, and the first URL corresponding to the URL suffix is read from the corresponding shard or table.
13. The method of claim 1, further comprising: In the event of a conflict, the parameters of the hash function are adjusted or additional information is added to regenerate the URL suffix.
14. The method of claim 1, wherein, The user's attribute information includes user ID, user geographical location, user device type, or user behavior data.
15. The method of claim 1, wherein, The access conditions include access time, access frequency, access source, or network environment.
16. The method of claim 1 or 10, further comprising: When a user visits the second URL, the user's access behavior is recorded for subsequent data analysis and access strategy optimization.
17. The method of claim 1, further comprising: Access to the second URL is controlled using an access security model, wherein the access security model is established based at least on the access IP, access device, access source, and access frequency per unit time.
18. The method of claim 1, further comprising: Regularly check whether the first URL is in the malicious website database; and / or Periodically crawl the webpage content corresponding to the first URL and call the risk control system to determine whether the webpage content is safe.
19. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 18.
20. A URL conversion and access control system, characterized in that, The system includes: URL generation device, used to generate a second URL based on a first URL; and A URL access device for controlling access when a user accesses the second URL; The URL generation device is configured to: hash a first URL using a hash function and perform encoding conversion to generate a URL suffix, wherein the character length of the URL suffix is shorter than the character length of the first URL; check whether the generated URL suffix conflicts with existing URL suffixes; and if there is no conflict, combine the URL suffix with the base domain name to form a second URL. And wherein, when a user accesses the second URL, the URL access device is configured to select one of the configured URL targets for redirection based on the user's attribute information and / or access conditions, wherein the configured URL targets include the first URL.
21. The system of claim 20, wherein, The URL generation device is configured to: The first URL is hashed using the MurmurHash function to obtain a hash value; The hash value is encoded in base-62 or base-36 to generate a string; as well as The generated string is truncated and padded to produce the URL suffix.
22. The system of claim 20, wherein, The URL generation device is configured to: Use a Bloom filter to determine if the generated URL suffix already exists; and If the result is "no", it is determined that the generated URL suffix does not conflict with existing URL suffixes.
23. The system of claim 22, wherein, The URL generation device is also configured to: If the condition is "yes", check the cache and database to see if the generated URL suffix exists; and If the generated URL suffix does not exist in either the cache or the database, it is determined that the generated URL suffix does not conflict with existing URL suffixes.
24. The system of claim 23, wherein, The URL generation device is also configured to: If the generated URL suffix exists in the cache or the database, output information related to the URL suffix.
25. The system of claim 20, wherein, The URL generation device is also configured to: When there is no conflict, the URL suffix is recorded in the Bloom filter, and the URL suffix is stored in the cache or database respectively according to the hot and cold data separation strategy.
26. The system of claim 20, wherein, The URL generation device is configured to: Receive each user's user ID; and The user identifier is combined with the first URL as input, and the MurmurHash function is used to perform hash processing and encoding conversion to generate the URL suffix.
27. The system of claim 20, wherein, The URL generation device is configured to: The MurmurHash function is used to hash and encode the first URL to generate the initial URL suffix; and Based on the current date and the initial URL suffix, a padding character is selected from the base string, wherein the initial URL suffix and the padding character are combined to obtain the generated URL suffix.
28. The system of claim 20, wherein, The URL generation device is also configured to: In the event of a conflict, the parameters of the hash function are adjusted or additional information is added to regenerate the URL suffix.
29. The system of claim 20, further comprising: The access analysis device is used to record the user's access behavior when the user accesses the second URL, and to perform data analysis and access strategy optimization.
30. The system of claim 20, wherein, The URL access device is configured to: Access to the second URL is controlled using an access security model, wherein the access security model is established based at least on the access IP, access device, access source, and access frequency per unit time.
31. The system of claim 20, further comprising: Access security devices are used to periodically check whether the first URL is in a malicious website database; And / or periodically crawl the web page content corresponding to the first URL, and call the risk control system to determine whether the web page content is safe.
