A method, system, device and medium for replacing a website external domain name link with a trusted intermediate domain name link
By extracting external domain links from the website database and generating intermediate trusted domain links, the problem of managing external domain links is solved, the separation of external domain links from the original website is achieved, and the website's security and the administrator's work efficiency are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIDIAN UNIV
- Filing Date
- 2024-09-03
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies cannot effectively separate and replace external domain name links of a website, allowing illegal websites to use legitimate domain names, affecting website security and making it difficult for administrators to handle.
By using regular expression matching to extract external domain links from the website database, generating intermediate trusted domain links, and replacing the external domain links with relay domains, the external domain links are separated from the original website.
It improves website security, reduces administrator workload, avoids the risk of temporary closure due to detection of external domain links, and ensures website stability and security.
Smart Images

Figure CN119202418B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of website link security technology, and in particular to a method, system, device, and medium for replacing external domain name links of a website with trusted intermediate domain name links. Background Technology
[0002] Users access the internet primarily through mobile applications and web pages. Mobile internet applications are booming, with 2.6 million active apps monitored in the domestic market, further covering users' daily learning, work, and life, and continuously strengthening the foundation for the Internet of Things. On the web page side, my country currently has approximately 3.87 million websites. Although this number is declining year by year, many online services are still provided through websites. The declining number of websites reflects a decrease in the number of management and maintenance personnel, and some websites have even been abandoned but not deregistered. This has led to a large number of poorly maintained websites being exploited and modified into harmful sites. Simultaneously, a large number of illegal overseas websites exist, and because their servers are located overseas, this further increases the difficulty of dealing with them and the harm they cause to society.
[0003] During routine maintenance of the campus website, the following phenomenon has been observed: Existing legitimate domain name links have been widely published on the campus intranet. When these legitimate domains, such as international conference domains like www.****.org, cease to be renewed after fulfilling their purpose or providing website services, they are illegally re-registered by individuals for use on illegal websites. These individuals intend to use the university website to promote their illegal sites, damaging the positive image of the educational institution and causing extremely negative consequences. Once a domain is used by an illegal website, the telecommunications security department detects it and demands immediate removal, threatening to cut off the school's telecommunications access otherwise. This creates significant challenges for administrators. Currently, administrators can only manually remove one illegal domain at a time, a very passive approach that fails to completely eradicate the problem.
[0004] To more thoroughly and comprehensively clean up and purify external links on existing websites, a method is proposed to separate external links of the campus website from the original website, ensuring the security of the original campus website's links.
[0005] Patent application CN112560399A discloses a method and apparatus for replacing page links. First, it obtains and saves page domain link replacement rules. Then, when a domain link button on the page is clicked, it obtains the domain link string to be replaced from the domain link corresponding to the button. According to the link replacement rules, it replaces the domain link string to be replaced with the target domain link string. Finally, it redirects to the replaced domain link. However, each domain link replacement rule needs to be saved separately; it does not actually separate the external domain link from the original website domain, only replacing the domain link string.
[0006] There's also a feature on Zhihu that replaces external domain links. When the external domain link is passed as a parameter and replaced with "link.*****.com / ****"external domain link", if the domain link is clicked, the user is first redirected to a warning page indicating they are about to leave Zhihu. Only after the user clicks "continue" will they be redirected to the external domain link. However, this feature requires reposting to process the external domain link; it cannot replace existing external domain links on the website. Summary of the Invention
[0007] To overcome the problems existing in the prior art, this invention proposes a method, system, device, and medium for replacing external domain name links of a website with trusted intermediate domain name links. The method involves searching website folders and databases to extract all external links and replacing them with trusted intermediate links using relay domain names. This reduces the workload of website administrators when modifying website links and publishing website content, and prevents users from directly redirecting to external links, thereby improving the security of the website itself. It is characterized by high efficiency and security.
[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0009] A method for replacing external domain links to a website with trusted intermediary domain links includes the following steps:
[0010] Step 1: Obtain external domain links for the website;
[0011] Step 2: Generating intermediate domain links;
[0012] Step 3: Replace the intermediate domain link: Replace the external domain link obtained in Step 1 with the intermediate domain link generated in Step 2 using the intermediate domain link, and create a trusted intermediate domain link.
[0013] The specific method for step 1 is as follows:
[0014] The system retrieves all links to website content by exporting files from the website database; it also collects external domain link data and saves all external domain links contained in the website by using regular expression string matching.
[0015] The method for searching external domain name link data in step 1 is as follows: based on the HTML source code... The `herf` attribute in the tag extracts the domain link content within the page. Then, it compares it with the website's main domain and uses string matching to match all domain links. Links that do not start with the main domain are external domain links. Finally, all external domain links contained in the website are saved.
[0016] The specific method for step 2 is as follows:
[0017] First, set up a relay website domain name on a web server in a data center or cloud server, and set up a function interface on the backend of the relay website as the access interface for the relay website. Then, based on the external domain name links obtained in step 1, number all external domain name links starting from 1. Then, concatenate the access interface of the relay website and use the external domain name link number as the parameter of the GET request to form the intermediate domain name link. Finally, store the external domain name links and intermediate domain name links one by one into a file or database.
[0018] The specific method for step 3 is as follows: replacement of the relay link:
[0019] For external domain links stored in files, the search is performed by traversing the folders where the relay websites are located; first, the external domain links that need to be replaced are read from the relay website database, and then the folders corresponding to the websites that need to be replaced are traversed, and the external domain link strings are replaced with the intermediate domain link strings.
[0020] For external domain links stored in the database, the external domain links that need to be replaced are first read from the database of the intermediary website. Then, the database is searched for content containing external domain links in a loop. Finally, the external domain link string is replaced with the corresponding intermediate domain link string through string matching.
[0021] A system for replacing external domain links to a website with trusted intermediary domain links includes:
[0022] External Domain Link Acquisition Module: Used in step 1, this module acquires and saves external domain links from the website. It searches website folders and exports files from the database, using string regular expression matching technology to obtain all links in the website content; it extracts external domain link data and saves all external domain links contained in the website.
[0023] Intermediate Domain Link Generation Module: Used to generate intermediate domain links in step 2; by setting up a relay website domain interface and matching and concatenating with the external domain link number, a one-to-one correspondence between external domain links and intermediate domain links is achieved.
[0024] Link replacement module: Used in step 3, it replaces the external domain links obtained in step 1 with the intermediate domain links generated in step 2 using the intermediate domain links, thus creating trusted intermediate domain links and replacing external domain links in the website.
[0025] A device for replacing external domain links to a website with trusted intermediary domain links, comprising:
[0026] Memory, used to store computer programs;
[0027] A processor, used to execute the computer program to implement the method described in steps 1 to 3 for replacing external domain name links of a website with trusted intermediate domain name links.
[0028] A computer-readable storage medium storing a computer program that, when executed by a processor, can replace external domain name links of a website with trusted intermediate domain name links based on the method described in steps 1 to 3.
[0029] Compared with the prior art, the present invention has the following beneficial effects:
[0030] This invention uses regular expression matching to extract all external domain links from the website database and processes these external domain links into trusted intermediate domain links, reducing the workload of website administrators when modifying website domain links and publishing website content.
[0031] This invention separates external domain name links from the original website domain name links by numbering them and then directly replacing them with intermediate website domain name links. This avoids the problem of parameter loss during the intermediate domain name link redirection process due to excessively long external domain name links, and ensures the security of website domain name links during scanning.
[0032] This invention extracts the external website links that need to be published and replaces them with trusted intermediate domain links using a relay domain method, thus preventing users from being directly redirected to the external domain links and improving the security of the website itself.
[0033] This invention separates external domain name links from the original website domain name links by replacing them with trusted intermediate domain name links. This avoids the need for temporary closure or other security checks on the original website if it is detected by relevant departments that the external domain name links may contain illegal domain name links.
[0034] In summary, this invention addresses the problems of difficult management and insecurity of external domain links to websites by replacing the original external domain links with trusted intermediate domain links. This separates the external domain links from the original website, improves website security, and avoids the need for temporary closure or other security checks if the original website is detected by relevant departments due to the possibility of illegal domain links in the external domain links. Attached Figure Description
[0035] Figure 1 This is a flowchart of the system design of the present invention.
[0036] Figure 2 A diagram showing the correspondence between some external domain links and intermediate domain links obtained for the website.
[0037] Figure 3 This is an image showing the effect of the original external domain link.
[0038] Figure 4 This is the redirect address for the original external domain link.
[0039] Figure 5 This is an image showing the effect of the replaced intermediate domain name link. Detailed Implementation
[0040] The present invention will now be described in further detail with reference to the accompanying drawings.
[0041] A method for replacing external domain links to a website with trusted intermediary domain links includes the following steps: See [link to method]. Figure 1
[0042] Step 1: Obtain external domain links for the website;
[0043] The system retrieves all links to website content by exporting files from the website database; it also collects external domain link data and saves all external domain links contained in the website by using regular expression string matching.
[0044] The method for collecting external domain name link data in step 1 is to collect data based on the HTML source code. The `herf` attribute in the tag extracts the link content within the page. Then, it compares it with the website's main domain. For example, if the website's main domain is www.ABC.org, then all domain links are matched using string matching. Domain links that do not start with www.ABC.org are external domain links. Finally, all external domain links contained in the website are saved.
[0045] Step 2: Generating intermediate domain links;
[0046] First, a relay website domain is set up on a web server such as Nginx or Apache in a data center or cloud server. Then, a function interface is set up on the backend of the relay website as the access interface for the relay website. Next, based on the obtained external domain links, all external domain links are numbered starting from 1. Then, the external domain link numbers are concatenated with the external domain link numbers in the relay website access interface as parameters of the GET request to form intermediate domain links. Finally, the external domain links and intermediate domain links are stored in a file or database in a one-to-one correspondence.
[0047] Step 3: Replacement of intermediate domain links: Replace the external domain links obtained in Step 1 with the intermediate domain links generated in Step 2 using the intermediate domain links generated in Step 2, thus creating trusted intermediate domain links;
[0048] Because different websites store domain links in different ways, external domain links may be stored in HTML, PHP, or other files, or they may exist in the website's own database. Therefore, when replacing website domain links, each method must be used to replace the other.
[0049] For external domain links stored in files, the search is performed by traversing the folders where the websites are located; first, the external domain links that need to be replaced are read from the database of the intermediate websites, and then the folders corresponding to the websites whose external domain links need to be replaced are traversed, and the external domain link strings are replaced with the intermediate domain link strings accordingly.
[0050] For external domain links stored in the database, the external domain links that need to be replaced are first read from the database of the intermediary website. Then, the database is searched for content containing external domain links in a loop. Finally, the external domain link string is replaced with the corresponding intermediate domain link string through string matching.
[0051] The technical effects of the present invention are further illustrated below through examples.
[0052] The process involves retrieving all links from a website using regular expression matching. First, the website's folder and corresponding database are exported. Then, a Java program iterates through all exported files, using string matching techniques to collect the HTML source code of the webpages, obtaining the actual HTML source code of the displayed content. Finally, external domain link data is collected and all external domain links contained within the website are saved.
[0053] Taking the website see.****.edu.cn as an example, the program first traverses the website folder and the exported database file, uses regular expression matching to obtain the external domain links of the website, and uses https: / / www.**** / api_url.php as the intermediate domain interface. The generated tsv files that correspond one-to-one between the intermediate domain links and the external domain links are as follows: Figure 2 As shown; the page with id 2 on the website is as follows Figure 3 As shown; accessing the link displays the page as follows. Figure 4 As shown;
[0054] Next, the external domain links to the website were replaced. After the replacement, the intermediate domain links will display as follows: Figure 5 As shown. Clicking the intermediate domain link will first redirect you to the intermediate domain link, and then the browser will automatically redirect you to the original address.
[0055] In summary, this invention achieves the replacement of external domain name links with trusted intermediate domain name links, realizes the separation of external domain name links and the original website, and verifies the effectiveness of this invention.
Claims
1. A method for replacing external domain name links of a website with trusted intermediate domain name links, characterized in that, Specifically, the following steps are included: Step 1: Obtain external domain links from the website; the method for collecting external domain link data is as follows: based on the HTML source code... The herf attribute in the tag extracts the domain link content within the page. Then, based on the comparison with the website's main domain, all domain links are matched using string matching. Links whose hostname part does not match the website's main domain are identified as external domain links. Finally, all external domain links contained in the website are saved. Step 2: Generation of intermediate domain links; First, build the domain name of the relay website using a web server in the data center or cloud server, and set up a function interface in the backend of the relay website as the access interface of the relay website. Then, based on the external domain links of the website obtained in Step 1, number all external domain links starting from 1. Then, concatenate the access interface of the relay website and use the external domain link number as the parameter of the GET request to form the intermediate domain links; After that, store the external domain links and intermediate domain links one by one into a file or database. Step 3: Replacement of intermediate domain links: Replace the external domain links obtained in Step 1 with the intermediate domain links generated in Step 2, using the intermediate domain links generated in Step 2 as a relay domain, to create trusted intermediate domain links; specifically: for external domain links stored in files, search by traversing the folders where the relay websites are located; first, read the external domain links that need to be replaced from the relay URL database, then traverse the folders corresponding to the URLs that need to be replaced, and replace the corresponding external domain link strings with intermediate domain link strings; For external domain links stored in the database, the external domain links that need to be replaced are first read from the database of the intermediary website. Then, the database is searched for content containing external domain links in a loop. Finally, the external domain link string is replaced with the corresponding intermediate domain link string through string matching.
2. The method for replacing external domain name links of a website with trusted intermediate domain name links according to claim 1, characterized in that, The specific method for step 1 is as follows: The system retrieves all links to website content by exporting files from the website database; it also collects external domain link data and saves all external domain links contained in the website by using regular expression string matching.
3. A system for replacing external domain name links of a website with trusted intermediate domain name links, characterized in that, To implement the method of claim 1 or 2, specifically including: An external domain link acquisition module is used to acquire external domain links in the website and save the external domain links; wherein, the external domain links are obtained by extracting links from the HTML source code of the webpage, matching the hostname of the link with the main domain name of the website, and identifying the links that do not match as external domain links; The intermediate domain link generation module is used to generate intermediate domain links that correspond one-to-one with the external domain links. Specifically, a relay website is built, and a unique number is assigned to each external domain link. The unique number is then used as a parameter to be concatenated into the access interface of the relay website to form the intermediate domain link. The correspondence between the external domain links and the intermediate domain links is stored in the storage medium. The link replacement module is used to replace the external domain name links in the webpage with the corresponding intermediate domain name links; wherein, for links stored in files, the files are traversed and string matching and replacement are performed; for links stored in the database, the database is queried and string matching and replacement are performed.
4. A device for replacing external domain name links of a website with trusted intermediate domain name links, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement, when executing the computer program, a method for replacing external domain name links of a website with trusted intermediate domain name links as described in claim 1 or 2.
5. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it can replace external domain name links of a website with trusted intermediate domain name links based on the method described in claim 1 or 2.