[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN109302437B - Method and device for redirecting website - Google Patents

Method and device for redirecting website Download PDF

Info

Publication number
CN109302437B
CN109302437B CN201710613289.8A CN201710613289A CN109302437B CN 109302437 B CN109302437 B CN 109302437B CN 201710613289 A CN201710613289 A CN 201710613289A CN 109302437 B CN109302437 B CN 109302437B
Authority
CN
China
Prior art keywords
website
address
terminal
domain name
redirection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710613289.8A
Other languages
Chinese (zh)
Other versions
CN109302437A (en
Inventor
金磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Fluorite Network Co ltd
Original Assignee
Hangzhou Fluorite Network Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Fluorite Network Co ltd filed Critical Hangzhou Fluorite Network Co ltd
Priority to CN201710613289.8A priority Critical patent/CN109302437B/en
Publication of CN109302437A publication Critical patent/CN109302437A/en
Application granted granted Critical
Publication of CN109302437B publication Critical patent/CN109302437B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/563Data redirection of data network streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a method and a device for redirecting a website, and belongs to the technical field of networks. The method comprises the following steps: receiving a DNS query request sent by a terminal, wherein the DNS query request carries a domain name of a website to be accessed, if a preset website redirection condition is met, sending a preset IP address to the terminal, and when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, acquiring a prestored address of a redirection website, and sending a redirection message to the terminal, wherein the redirection message carries the address of the redirection website, so that the terminal accesses the redirection website. By adopting the invention, a method for redirecting the website by other equipment and complying with the http protocol is provided.

Description

Method and device for redirecting website
Technical Field
The present invention relates to the field of network technologies, and in particular, to a method and an apparatus for redirecting a website.
Background
In the prior art, a method for redirecting a website generally includes that a server sends a redirection message to a terminal after receiving a webpage acquisition request sent by the terminal, and carries an address of a redirected website therein, and the terminal can access the redirected website based on the address of the redirected website.
Thus, the prior art only proposes a method for redirecting a website by a server, and does not propose a method for redirecting a website on other devices (such as a routing device) and complying with the http protocol.
Disclosure of Invention
In order to solve the problem of poor user experience, embodiments of the present invention provide a method and an apparatus for redirecting a website. The technical scheme is as follows:
in a first aspect, a method for redirecting a website is provided, the method comprising:
receiving a DNS query request sent by a terminal, wherein the DNS query request carries a domain name of a website to be accessed;
if the preset website redirection condition is met, sending a preset IP address to the terminal;
when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, acquiring the address of a prestored redirection website;
and sending a redirection message to the terminal, wherein the redirection message carries the address of the redirection website, so that the terminal accesses the redirection website.
Optionally, the address of the redirection website is a domain name and an IP address.
Optionally, if the domain name of the website to be visited meets a preset website redirection condition, sending a preset IP address to the terminal includes:
and if the device is detected not to be accessed to the network, sending a preset IP address to the terminal.
Optionally, if the domain name of the website to be visited meets a preset website redirection condition, sending a preset IP address to the terminal includes:
if the old domain name in the pre-stored corresponding relation between the new domain name and the old domain name comprises the domain name of the website to be accessed, sending a preset IP address to the terminal;
if the IP address carried in the web page obtaining request is the preset IP address, obtaining the address of the prestored redirection website, including:
and if the IP address carried in the webpage obtaining request is the preset IP address, obtaining a new domain name corresponding to the domain name of the website to be accessed in the pre-stored corresponding relationship between the new domain name and the old domain name, and using the new domain name as the address of the redirection website.
Optionally, after sending the preset IP address to the terminal, the method further includes:
and establishing TCP connection with the terminal based on the preset IP address.
In a second aspect, an apparatus for redirecting a website is provided, the apparatus comprising:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a DNS query request sent by a terminal, and the DNS query request carries a domain name of a website to be accessed;
the sending module is used for sending a preset IP address to the terminal if a preset website redirection condition is met;
the acquiring module is used for acquiring the address of a prestored redirection website if the IP address carried in the webpage acquiring request is the preset IP address when the webpage acquiring request sent by the terminal is received;
the sending module is configured to send a redirection packet to the terminal, where the redirection packet carries an address of the redirection website, so that the terminal accesses the redirection website.
Optionally, the address of the redirection website is a domain name and an IP address.
Optionally, the sending module is configured to:
and if the device is detected not to be accessed to the network, sending a preset IP address to the terminal.
Optionally, the sending module is configured to:
if the old domain name in the pre-stored corresponding relation between the new domain name and the old domain name comprises the domain name of the website to be accessed, sending a preset IP address to the terminal;
the obtaining module is configured to:
and if the IP address carried in the webpage obtaining request is the preset IP address, obtaining a new domain name corresponding to the domain name of the website to be accessed in the pre-stored corresponding relationship between the new domain name and the old domain name, and using the new domain name as the address of the redirection website.
Optionally, the apparatus further comprises:
and the connection module is used for establishing TCP connection with the terminal based on the preset IP address.
In a third aspect, an apparatus for redirecting a website is provided, the apparatus comprising a processor and a memory, wherein:
the memory is used for storing a computer program;
the processor is configured to implement the method for redirecting a website according to the first aspect when executing the program stored in the memory.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, a router receives a DNS query request sent by a terminal, if the DNS query request meets a preset website redirection condition, a preset IP address is sent to the terminal, and when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, the address of a pre-stored redirection website is acquired, and a redirection message is sent to the terminal.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart illustrating a method for redirecting a website according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for redirecting a website according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for redirecting a website according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for redirecting a website according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an apparatus for redirecting a website according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
The embodiment of the invention provides a method for redirecting a website, wherein an execution main body of the method can be network equipment connected with a terminal, such as a router, a repeater, a switch and the like, and the terminal can be a mobile phone, a tablet computer, a computer and the like. The network device may be provided with a processor, a memory, a transceiver, and the like, where the processor may be used for processing in the process of redirecting a website, the memory may be used for data required and generated in the process of redirecting a website, and the transceiver may be used for receiving and sending messages, and the like. In this embodiment, a network device is taken as an example to describe the scheme in detail, and other situations are similar to the above, and the description of this embodiment is not repeated.
As shown in fig. 1, the processing flow of the method may include the following steps:
step 101, a terminal receives a domain name of a website to be accessed, which is input by a user, and sends a DNS query request to a router.
In the implementation, a user wants to use the terminal to access a certain website on the internet, a browser installed in the terminal can be opened, the terminal can display a main interface of the browser, and a website input box and corresponding search options are displayed in the main interface. The user may input a website address of a website to be visited in the website address input box, where the website address refers to a domain name, then the user may click a search option, the terminal may receive a click instruction of the search option, and the terminal may obtain a main domain name (which may be referred to as a domain name of a website to be visited later) in the website address input by the user, where the website address is www.taotao.com/u/1234.htm, and the main domain name is www.taotao.com. Then, a Domain Name System (DNS) query request is sent to the router, and the DNS query request carries the Domain Name of the website to be accessed.
It should be noted that, if the above-mentioned terminal is a computer, after the user opens the browser, the website input box is at the position where the website of the current interface is displayed. If the terminal is a mobile phone, the website input box is the search input box after the user opens the browser.
Step 102, a router receives a DNS query request sent by a terminal, where the DNS query request carries a domain name of a website to be accessed.
And 103, if the preset website redirection condition is met, the router sends a preset IP address to the terminal.
Among them, a preset IP (Internet Protocol) address may be set by a technician and stored in a router, such as 1.125.125.254. Preset website redirection conditions may also be set by a technician and stored in a router, such as the router not accessing the network.
In implementation, a technician sets a kernel hook function in a router, and the kernel hook function can be added to a thread for executing message forwarding, and is used for intercepting and identifying a received message. When the router receives a DNS query request sent by a terminal, the kernel hook function may intercept the DNS query request and identify content in the message. If the preset website redirection condition is met, the preset IP address can be obtained, and then the preset IP address is sent to the terminal.
It should be noted that the function for executing message interception and recognition is a kernel hook function, and any function that can be used for executing message interception and recognition is applicable to the embodiment of the present invention, which is not limited in the embodiment of the present invention.
And 104, the terminal receives the preset IP address sent by the router and sends a webpage acquisition request to the router.
In implementation, after receiving a preset IP address sent by a router, a terminal may send a web page acquisition request to the router, where the web page acquisition request may be an http service request, and carries the preset IP address and a GET (GET) identifier.
And 105, when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is a preset IP address, the router acquires the address of the pre-stored redirection website.
Wherein, the address of the redirection website can be stored in the router in advance.
In implementation, after the router receives a webpage acquisition request sent by the terminal, the thread where the kernel hook function is located in the router can intercept and identify the webpage acquisition request, and if the IP address carried in the webpage acquisition request is a preset IP address, the router can acquire a prestored website of the redirection website.
In addition, if the IP address carried in the web page obtaining request is the preset IP address, it may be further determined whether the identifier in the web page obtaining request is a GET identifier, and if the identifier is a GET indication, a pre-stored address of the redirection website may be obtained.
Optionally, the address of the redirection website is a domain name and an IP address.
And 106, the router sends a redirection message to the terminal, wherein the redirection message carries the address of the redirection website.
Wherein the redirection message is an http302 redirection message.
In implementation, after acquiring the address of the redirection website, the router may send a redirection packet to the terminal, where the redirection packet carries the address of the redirection website. For example, the address of the redirection website is IP address 10.10.10.10, and the redirection packet may be as follows:
“HTTP/1.1 302Moved Temporarily\r\n"
"Server:boa 1.1\r\n"
"Date:Sat,21Dec 2009 12:00:00GMT\r\n"
"Connection:close\r\n"
"cache-Control:no-cache\r\n"
"Content-Type:text/html\r\n"
"Location:10.10.10.10\r\n"
"<html><body><br><br></body></html>\r\n”
and step 107, the terminal receives the redirection message and accesses the address of the redirection website carried in the redirection message.
In implementation, after receiving the redirection packet sent by the router, the terminal may access the redirection website by using the address of the redirection website carried in the redirection packet, and the detailed processing procedure is described in detail later.
As shown in fig. 2, if the preset website redirection condition is that the router does not access the network, the execution flow of the embodiment of the present invention may be as follows:
step 201, the terminal receives a domain name of a website to be accessed, which is input by a user, and sends a DNS query request to the router.
The processing procedure is the same as that of step 101, and is not described herein again.
Step 202, the router receives a DNS query request sent by the terminal, where the DNS query request carries a domain name of a website to be accessed.
The processing procedure is the same as that of step 102, and is not described here again.
Step 203, if it is detected that the device does not access the network, a preset IP address is sent to the terminal.
Where the preset IP address may be set by a technician and stored in the router, such as 1.125.125.254.
In implementation, a technician sets a kernel hook function in a router, and the kernel hook function can be added to a thread for executing message forwarding, and is used for intercepting and identifying a received message. When the router receives a DNS query request sent by a terminal, the kernel hook function may intercept the DNS query request and identify content in the message. If the device is detected to be incapable of forwarding the DNS query request, the device is determined not to be accessed to the network, a preset IP address can be obtained, and then the preset IP address is sent to the terminal. After receiving the preset IP address sent by the router, the terminal may send a web page acquisition request to the router, where the web page acquisition request may be an http service request, and carries the preset IP address and GET (acquisition) identifier.
It should be noted that the function for executing message interception and recognition is a kernel hook function, and any function that can be used for executing message interception and recognition is applicable to the embodiment of the present invention, which is not limited in the embodiment of the present invention.
In step 204, the terminal receives the preset IP address sent by the router.
The processing is the same as that in step 104, and is not described here again.
Step 205, the router establishes a TCP connection with the terminal based on the preset IP address, and the terminal sends a web page acquisition request to the router.
In implementation, after receiving a preset IP address sent by a router, a terminal may initiate a TCP (Transmission Control Protocol) connection to a device corresponding to the preset IP, specifically, a TCP SYN (synchronization) message may be sent to the router, after receiving the TCP SYN message sent by the terminal, the router determines that the IP address is the preset IP address, and may send a TCP SYN + ACK (acknowledgement character) message to the terminal, after receiving the TCP SYN + ACK message sent by the router, the terminal may send a TCP ACK message to the router, and then send a web page acquisition request, which may be an http service request, which carries the preset IP address and a GET (GET) identifier.
Step 206, when receiving a web page obtaining request sent by the terminal, if the IP address carried in the web page obtaining request is a preset IP address, the router obtains the address of the pre-stored redirection website.
In implementation, after the router receives a web page acquisition request sent by the terminal, the thread where the kernel hook function is located in the router can intercept and identify the web page acquisition request, and if the IP address carried in the web page acquisition request is a preset IP address, the router can acquire a pre-stored website address of a redirection website, wherein the pre-stored website address of the redirection website is a website address of a network connection interface and can be a domain name or an IP address.
Step 207, the router sends a redirection message to the terminal, wherein the redirection message carries the address of the redirection website.
The technical personnel prestores the network connection interface corresponding to the website of the network connection interface in the router.
In the implementation, the process of sending the redirect packet to the terminal by the router is the same as the process of step 104, and is not described herein again.
And step 208, the terminal receives the redirection message and accesses the address of the redirection website carried in the redirection message.
In implementation, after receiving the redirection packet sent by the router, the terminal may obtain an address of a redirection website therein, if the address of the redirection website is an IP address, the terminal may establish a TCP connection to a device corresponding to the IP address (the same as the processing in step 203), and then send a web page acquisition request to the router, after receiving the web page acquisition request, the router may search for a network connection interface corresponding to a website carried in the web page acquisition request, and then send the network connection interface to the terminal, the terminal may receive and display the network connection interface, and the user may input an account number and a password to perform a connection operation. If the address of the redirection website is a domain name, the domain name is a domain name of the network connection interface, the terminal may send a DNS query request to the router, where the DNS query request carries the domain name of the network connection interface, and after the router receives the DNS query request sent by the terminal, a thread in which a kernel hook function in the router is located may identify the DNS query request, and if the domain name is a domain name corresponding to the network connection interface, an IP address corresponding to the network connection interface may be fed back to the terminal, and after the terminal receives the IP address sent by the router, a TCP connection may be established with a device corresponding to the IP address (the same as the processing in step 203). And then sending a webpage acquisition request to the router, after receiving the webpage acquisition request, the router can search a network connection interface corresponding to the website carried in the webpage acquisition request, then sending the network connection interface to the terminal, and the terminal can receive and display the network connection interface, so that a user can input an account and a password to perform connection operation.
It should be noted that, since the IP address in step 208 is the network address of the network connection interface, and the network connection interface is stored in the router, the IP address is the IP address of the router, and the corresponding device is the router.
Therefore, under the condition that the router does not have access to the network, the terminal sends the DNS query request, can receive the preset IP address instead of displaying the notification that the webpage acquisition fails, can also establish TCP connection with the router by using the preset IP address, and then the router sends the website of the network connection interface to the terminal. Therefore, the webpage jump is realized on the basis of not changing the http protocol.
As shown in fig. 3, the preset website redirection condition is that the old domain name in the pre-stored correspondence between the new domain name and the old domain name includes the domain name of the website to be accessed, and the execution flow of the embodiment of the present invention may be as follows:
step 301, the terminal receives a domain name of a website to be accessed, which is input by a user, and sends a DNS query request to the router.
The processing procedure is the same as that of step 101, and is not described herein again.
Step 302, the router receives a DNS query request sent by the terminal, where the DNS query request carries a domain name of a website to be accessed.
The processing procedure is the same as that of step 102, and is not described here again.
Step 303, if the old domain name in the pre-stored correspondence between the new domain name and the old domain name includes the domain name of the website to be accessed, sending a preset IP address to the terminal.
In implementation, a technician prestores a correspondence between a new domain name and an old domain name in a router, and the new domain name and the corresponding old domain name belong to two domain names of the same website in the correspondence. Or, the router may crawl a new domain name and an old domain name of the website from the network every preset time, for example, the router visits announcements of each website every other week, determines whether to change the domain name, and then adds the new domain name and the old domain name into the corresponding relationship between the new domain name and the old domain name.
After the router receives a DNS query request sent by a terminal, a thread where a kernel hook function is located in the router can identify a domain name of a website to be accessed carried in the router, and if an old domain name in a corresponding relation between a new domain name and an old domain name comprises the domain name of the website to be accessed, the router can acquire a preset IP address and send the preset IP address to the terminal.
In step 304, the terminal receives the preset IP address sent by the router.
The processing is the same as that in step 104, and is not described here again.
Step 305, the router establishes a TCP connection with the terminal based on the preset IP address, and the terminal sends a web page acquisition request to the router.
In implementation, after receiving a preset IP address sent by a router, a terminal may initiate TCP connection to a device corresponding to the preset IP, specifically, the terminal may send a TCP SYN message to the router, after receiving the TCP SYN message sent by the terminal, the router determines that the IP address is the preset IP address, and may send a TCP SYN + ACK message to the terminal, and after receiving the TCP SYN + ACK message sent by the router, the terminal may send a TCP ACK message to the router, and then sends a web page acquisition request to the router, where the web page acquisition request may be an http service request, where the http service request carries the preset IP address and GET (acquisition) identifier.
Step 306, if the IP address carried in the web page obtaining request is a preset IP address, obtaining a new domain name corresponding to the domain name of the website to be accessed in the pre-stored correspondence between the new domain name and the old domain name, and using the new domain name as the address of the redirection website.
In implementation, after the router receives a webpage acquisition request sent by a terminal, a thread where a kernel hook function is located in the router can intercept and identify the webpage acquisition request, if an IP address carried in the webpage acquisition request is a preset IP address, a new domain name corresponding to a domain name of a website to be accessed can be determined in a corresponding relation between the new domain name and an old domain name, and the new domain name is used as an address of a redirection website.
Optionally, the router caches a corresponding relationship between a new domain name and an IP address, and after determining the new domain name corresponding to the domain name of the website to be accessed, the router may determine the IP address corresponding to the new domain name in the corresponding relationship between the new domain name and the IP address, and use the IP address as the address of the redirection website.
Step 307, the router sends a redirection packet to the terminal, where the redirection packet carries an address of the redirection website, so that the terminal accesses the redirection website.
In the implementation, the process of sending the redirect packet to the terminal by the router is the same as the process of step 104, and is not described herein again.
And 308, the terminal receives the redirection message and accesses the address of the redirection website carried in the redirection message.
In implementation, after receiving the redirection packet sent by the router, the terminal may obtain an address of the redirection website therein, and if the address of the redirection website is an IP address, the terminal may establish a TCP connection to the device to which the IP address belongs (the same as the processing in step 203), and then send a web page acquisition request to the router, where the web page acquisition request is carried with the IP address, after receiving the web page acquisition request, the router may forward the web page acquisition request to the device to which the IP address carried in the web page acquisition request belongs, and the device sends a web page corresponding to the IP address to the terminal. If the address of the redirection site is a domain name, the terminal may send a DNS query request to the router, wherein, the domain name is carried, after the router receives the DNS query request, the old domain name in the corresponding relation of the new domain name and the old domain name is determined not to comprise the domain name, the DNS query request may be forwarded to a domain name server, which may query the IP address corresponding to the domain name, then the IP address is sent to the terminal, after the terminal receives the IP address sent by the domain name server, a TCP connection may be established with the device to which the IP address belongs (same process as step 203) and then a web page fetch request is sent to the router, the router can forward the web page acquisition request to the device to which the IP address carried in the web page acquisition request belongs after receiving the web page acquisition request, and the device sends the web page corresponding to the IP address to the terminal.
In the embodiment of the invention, the terminal sends a DNS query request, can receive a preset IP address instead of displaying a notice of webpage acquisition failure, can establish TCP connection with a router by using the preset IP address, then the router sends the website of the redirected website to the terminal, redirects the website to the redirected website under the condition of not changing the execution process of the terminal, and can access the redirected website by the terminal, thereby realizing the redirected website, enabling the domain name displayed in the browser to correspond to the displayed website and not changing the http protocol.
In the embodiment of the invention, a router receives a DNS query request sent by a terminal, if the DNS query request meets a preset website redirection condition, a preset IP address is sent to the terminal, and when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, the address of a pre-stored redirection website is acquired, and a redirection message is sent to the terminal.
Based on the same technical concept, an embodiment of the present invention further provides a device for redirecting a website, as shown in fig. 4, the device includes:
a receiving module 410, configured to receive a DNS query request sent by a terminal, where the DNS query request carries a domain name of a website to be accessed;
a sending module 420, configured to send a preset IP address to the terminal if a preset website redirection condition is met;
an obtaining module 430, configured to, when a webpage obtaining request sent by the terminal is received, if an IP address carried in the webpage obtaining request is the preset IP address, obtain a pre-stored address of a redirection website;
the sending module 420 is configured to send a redirection packet to the terminal, where the redirection packet carries an address of the redirection website, so that the terminal accesses the redirection website.
Optionally, the address of the redirection website is a domain name and an IP address.
Optionally, the sending module 420 is configured to:
and if the device is detected not to be accessed to the network, sending a preset IP address to the terminal.
Optionally, the sending module 420 is configured to:
if the old domain name in the pre-stored corresponding relation between the new domain name and the old domain name comprises the domain name of the website to be accessed, sending a preset IP address to the terminal;
the obtaining module 430 is configured to:
and if the IP address carried in the webpage obtaining request is the preset IP address, obtaining a new domain name corresponding to the domain name of the website to be accessed in the pre-stored corresponding relationship between the new domain name and the old domain name, and using the new domain name as the address of the redirection website.
Optionally, as shown in fig. 5, the apparatus further includes:
a connection module 440, configured to establish a TCP connection with the terminal based on the preset IP address.
In the embodiment of the invention, the router receives a DNS query request sent by the terminal, if the preset website redirection condition is met, the preset IP address is sent to the terminal, and when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, the address of the pre-stored redirection website is acquired, and a redirection message is sent to the terminal. Thus, a method for other devices to redirect websites and comply with the http protocol is proposed.
It should be noted that: in the device for redirecting a website according to the foregoing embodiment, when the website is redirected, only the division of the functional modules is illustrated, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the apparatus for redirecting a website and the method embodiment for redirecting a website provided in the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiment and will not be described herein again.
Referring to fig. 6, a schematic structural diagram of a device according to an embodiment of the present invention is shown, where the device may be used to implement the method for redirecting a website provided in the foregoing embodiment. Specifically, the method comprises the following steps:
the device 600 may include RF (Radio Frequency) circuitry 110, memory 120 including one or more computer-readable storage media, a processor 130 including one or more processing cores, and so on. Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 6 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 110 may be used to transmit and receive information, receive and transmit signals, the memory 120 may be used to store software programs and modules, and the processor 130 may execute various functional applications and data processing by operating the software programs and modules stored in the memory 120. The memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to the use of the apparatus 600, and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 120 may also include a memory controller to provide the processor 130 access to the memory 120.
The processor 130 is the control center of the device 600, connects various parts of the entire device using various interfaces and lines, and performs various functions of the device 600 and processes data by running or executing software programs and/or modules stored in the memory 120 and calling data stored in the memory 120, thereby performing overall monitoring of the mobile phone. Optionally, processor 130 may include one or more processing cores.
Apparatus 600 also includes a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for:
receiving a DNS query request sent by a terminal, wherein the DNS query request carries a domain name of a website to be accessed;
if the preset website redirection condition is met, sending a preset IP address to the terminal;
when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, acquiring the address of a prestored redirection website;
and sending a redirection message to the terminal, wherein the redirection message carries the address of the redirection website, so that the terminal accesses the redirection website.
Optionally, the address of the redirection website is a domain name and an IP address.
Optionally, if the domain name of the website to be visited meets a preset website redirection condition, sending a preset IP address to the terminal includes:
and if the device is detected not to be accessed to the network, sending a preset IP address to the terminal.
Optionally, if the domain name of the website to be visited meets a preset website redirection condition, sending a preset IP address to the terminal includes:
if the old domain name in the pre-stored corresponding relation between the new domain name and the old domain name comprises the domain name of the website to be accessed, sending a preset IP address to the terminal;
if the IP address carried in the web page obtaining request is the preset IP address, obtaining the address of the prestored redirection website, including:
and if the IP address carried in the webpage obtaining request is the preset IP address, obtaining a new domain name corresponding to the domain name of the website to be accessed in the pre-stored corresponding relationship between the new domain name and the old domain name, and using the new domain name as the address of the redirection website.
Optionally, after sending the preset IP address to the terminal, the method further includes:
and establishing TCP connection with the terminal based on the preset IP address.
In the embodiment of the invention, a router receives a DNS query request sent by a terminal, if the DNS query request meets a preset website redirection condition, a preset IP address is sent to the terminal, and when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, the address of a pre-stored redirection website is acquired, and a redirection message is sent to the terminal.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (9)

1. A method for redirecting a website is applied to a network device accessed by a terminal, and the method comprises the following steps:
receiving a Domain Name System (DNS) query request sent by a terminal, wherein the DNS query request carries a domain name of a website to be accessed;
if the network equipment is detected not to be accessed to the network, sending a preset IP address to the terminal;
establishing a Transmission Control Protocol (TCP) connection with the terminal based on the preset IP address;
when a webpage acquisition request sent by the terminal is received, if the IP address carried in the webpage acquisition request is the preset IP address, acquiring a pre-stored website of a network connection interface as the address of a redirection website;
sending a redirection message to the terminal, wherein the redirection message carries an address of the redirection website, so that the terminal accesses the redirection website;
and when receiving a webpage acquisition request of the redirection website sent by the terminal, sending the network connection interface to the terminal so that a user of the terminal inputs an account and a password in the network connection interface to access the network for the network equipment.
2. The method of claim 1, wherein the address of the redirection website is a domain name and an IP address.
3. A method for redirecting a website is applied to a network device accessed by a terminal, and the method comprises the following steps:
receiving a Domain Name System (DNS) query request sent by a terminal, wherein the DNS query request carries a domain name of a website to be accessed;
if the old domain name in the pre-stored corresponding relation between the new domain name and the old domain name comprises the domain name of the website to be accessed, sending a preset IP address to the terminal;
establishing a Transmission Control Protocol (TCP) connection with the terminal based on the preset IP address;
when a webpage acquisition request sent by the terminal is received, if an IP address carried in the webpage acquisition request is the preset IP address, acquiring a new domain name corresponding to the domain name of the website to be accessed from the pre-stored corresponding relationship between the new domain name and the old domain name, and determining the address of a redirected website based on the new domain name corresponding to the website to be accessed;
and sending a redirection message to the terminal, wherein the redirection message carries the address of the redirection website, so that the terminal accesses the redirection website.
4. The method of claim 3, wherein the address of the redirection website is a domain name and an IP address.
5. An apparatus for redirecting a website, the apparatus being applied to a network device accessed by a terminal, the apparatus comprising:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a domain name system DNS query request sent by a terminal, and the DNS query request carries a domain name of a website to be accessed;
a sending module, configured to send a preset IP address to the terminal if it is detected that the network device is not accessed to the network;
the connection module is used for establishing Transmission Control Protocol (TCP) connection with the terminal based on the preset IP address;
the acquisition module is used for acquiring a pre-stored website of the network connection interface as the address of a redirection website if the IP address carried in the webpage acquisition request is the preset IP address when the webpage acquisition request sent by the terminal is received;
the sending module is further configured to:
sending a redirection message to the terminal, wherein the redirection message carries an address of the redirection website, so that the terminal accesses the redirection website;
and when receiving a webpage acquisition request of the redirection website sent by the terminal, sending a network connection interface to the terminal so that a user of the terminal inputs an account and a password in the network connection interface to access a network for the network equipment.
6. The apparatus of claim 5, wherein the address of the redirection website is a domain name and an IP address.
7. An apparatus for redirecting a website, the apparatus being applied to a network device accessed by a terminal, the apparatus comprising:
the system comprises a receiving module, a sending module and a receiving module, wherein the receiving module is used for receiving a domain name system DNS query request sent by a terminal, and the DNS query request carries a domain name of a website to be accessed;
a sending module, configured to send a preset IP address to the terminal if an old domain name in a pre-stored correspondence between a new domain name and an old domain name includes the domain name of the website to be accessed;
the connection module is used for establishing Transmission Control Protocol (TCP) connection with the terminal based on the preset IP address;
an obtaining module, configured to, when a web page obtaining request sent by the terminal is received, if an IP address carried in the web page obtaining request is the preset IP address, obtain, in the correspondence between the pre-stored new domain name and old domain name, a new domain name corresponding to the domain name of the website to be accessed, and determine, based on the new domain name corresponding to the website to be accessed, an address of a redirect website;
the sending module is further configured to send a redirection packet to the terminal, where the redirection packet carries an address of the redirection website, so that the terminal accesses the redirection website.
8. The apparatus of claim 7, wherein the address of the redirection website is a domain name and an IP address.
9. An apparatus for redirecting a website, comprising a processor and a memory, wherein:
the memory is used for storing a computer program;
the processor, when executing the program stored in the memory, is adapted to perform the method steps of any of claims 1-2 or to perform the method steps of any of claims 3-4.
CN201710613289.8A 2017-07-25 2017-07-25 Method and device for redirecting website Active CN109302437B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710613289.8A CN109302437B (en) 2017-07-25 2017-07-25 Method and device for redirecting website

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710613289.8A CN109302437B (en) 2017-07-25 2017-07-25 Method and device for redirecting website

Publications (2)

Publication Number Publication Date
CN109302437A CN109302437A (en) 2019-02-01
CN109302437B true CN109302437B (en) 2022-01-11

Family

ID=65167346

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710613289.8A Active CN109302437B (en) 2017-07-25 2017-07-25 Method and device for redirecting website

Country Status (1)

Country Link
CN (1) CN109302437B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110933129A (en) * 2019-10-18 2020-03-27 网宿科技股份有限公司 Data scheduling method, plug-in, device and scheduling server
CN110719169A (en) * 2019-11-07 2020-01-21 北京小米移动软件有限公司 Method and device for transmitting router safety information
CN111953761B (en) * 2020-08-04 2023-07-25 Oppo广东移动通信有限公司 Data processing method, device, electronic equipment and storage medium
CN113194065A (en) * 2021-03-17 2021-07-30 广州根链国际网络研究院有限公司 DNS attack protection method and system
CN114154099B (en) * 2021-12-07 2024-07-09 北京达佳互联信息技术有限公司 Routing information processing method, device, equipment and storage medium
CN114745434A (en) * 2022-04-06 2022-07-12 北京三快在线科技有限公司 Method, device, equipment and storage medium for proxy network request

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103780654A (en) * 2012-10-24 2014-05-07 华为技术有限公司 Business request processing method, user terminal, business router and network system
CN104010051A (en) * 2014-06-05 2014-08-27 胡汉强 Network access method, network access device and management server
CN104243627A (en) * 2014-08-29 2014-12-24 华为技术有限公司 Domain name resolution method, device and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103780654A (en) * 2012-10-24 2014-05-07 华为技术有限公司 Business request processing method, user terminal, business router and network system
CN104010051A (en) * 2014-06-05 2014-08-27 胡汉强 Network access method, network access device and management server
CN104243627A (en) * 2014-08-29 2014-12-24 华为技术有限公司 Domain name resolution method, device and system

Also Published As

Publication number Publication date
CN109302437A (en) 2019-02-01

Similar Documents

Publication Publication Date Title
CN109302437B (en) Method and device for redirecting website
JP6256896B2 (en) Page redirection method, routing device, terminal device and system
CN107181779B (en) Method, device and system for processing access request
CN102904959B (en) Network accelerating method and gateway
US9565161B2 (en) Automatically replacing localhost as hostname in URL with fully qualified domain name or IP address
US20230079314A1 (en) Service server switching control method and apparatus, electronic device, and storage medium
CN110730196B (en) Network resource access method, computer equipment and storage medium
US20160234307A1 (en) Data transmission method, device, and system
CN110213331B (en) Service request processing method, terminal device, electronic device and storage medium
CN109889468B (en) Network data transmission method, system, device, equipment and storage medium
CN112565406B (en) Gray release method, gray release system and electronic equipment
US20160100025A1 (en) Ui framework support for portal systems
EP3525411B1 (en) Terminal authentication method and device
US20230078344A1 (en) Switching control method and apparatus for service server, electronic device, and storage medium
KR20220158018A (en) Connection Establishment Method, Communication Device, and System
CN112751917A (en) Resource file loading method, network device, electronic device and storage medium
US11870836B2 (en) Accelerating connections to a host server
CN108347460B (en) Resource access method and device
US11706301B2 (en) Server node selection method and terminal device
CN113923008B (en) Malicious website interception method, device, equipment and storage medium
CN106411978B (en) Resource caching method and device
JP6074550B2 (en) Web page push method and apparatus, and terminal
CN111866211B (en) Network access method, device, terminal and medium applied to terminal
CN111416851A (en) Method for session synchronization among multiple load balancers and load balancer
KR20040008189A (en) Requests in a communication system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: No. 555, Qianmo Road, Binjiang District, Hangzhou, Zhejiang 310000

Applicant after: Hangzhou fluorite Network Co.,Ltd.

Address before: No. 555, Qianmo Road, Binjiang District, Hangzhou, Zhejiang 310000

Applicant before: HANGZHOU EZVIZ NETWORK Co.,Ltd.

GR01 Patent grant
GR01 Patent grant