CN110879870A - Page redirection method and device based on HTTP request - Google Patents

Page redirection method and device based on HTTP request Download PDF

Info

Publication number
CN110879870A
CN110879870A CN201911086479.4A CN201911086479A CN110879870A CN 110879870 A CN110879870 A CN 110879870A CN 201911086479 A CN201911086479 A CN 201911086479A CN 110879870 A CN110879870 A CN 110879870A
Authority
CN
China
Prior art keywords
http request
redirection
judging whether
page
website
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.)
Pending
Application number
CN201911086479.4A
Other languages
Chinese (zh)
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.)
Shenzhen Hua Hua Software Technology Co Ltd
Original Assignee
Shenzhen Hua Hua Software Technology 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 Shenzhen Hua Hua Software Technology Co Ltd filed Critical Shenzhen Hua Hua Software Technology Co Ltd
Priority to CN201911086479.4A priority Critical patent/CN110879870A/en
Publication of CN110879870A publication Critical patent/CN110879870A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0241Advertisements
    • G06Q30/0277Online advertisement
    • 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]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Game Theory and Decision Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • General Business, Economics & Management (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention relates to a page redirection method and a device based on HTTP request, the method comprises the following steps: receiving an HTTP request; judging whether a destination port of the HTTP request is TCP 80; determining whether the HTTP request is from a web browser; and judging whether the object of the HTTP request is a website, if so, redirecting the HTTP request, and otherwise, discarding the HTTP request message. The invention can reduce the redirection times and optimize the redirection efficiency, thereby improving the internet experience of the user.

Description

Page redirection method and device based on HTTP request
Technical Field
The invention relates to the technical field of network communication, in particular to a page redirection method and device based on an HTTP request.
Background
Many applications redirect a browsing request of a user to a link preset by an operator or specified by a service provider by using an HTTP redirection mode so as to achieve specific purposes of pushing advertisements and the like.
Currently, there are three main implementations of HTTP redirection:
1. the method comprises the following steps that a classic ajax request initiates an HTTP request in a post mode, a server responds to a page address, a client side splices parameters, and a new page is opened in a window. Or the server can directly splice the parameters, return a complete url address and jump the client through JS.
2. 301 redirect, which represents permanent move (301 redirect), 301 redirect is the best method for search engine friendliness after web pages change addresses, and 301 redirect can be used to make a move as long as it is not a temporary move.
3. 302 redirect, which represents a temporal move, that many BlackHat SEOs have been widely used in the past years as a technical cheat, and now, every major search engine has intensified the strength of hit, like Google's king of domain names (Business) in the past years and the recent punishment of BMW german websites. Even if the website is not spam (search engine spam technology) objectively, the website is easily misjudged as spam by the search engine and is punished.
The advertisement pushing mode of an operator and a device/service provider (such as a router manufacturer or a wireless gateway customized by a certain service provider) is generally realized by a 302 redirection mode, and currently, when a user continuously browses a webpage by adopting 302 redirection, the redirection frequency cannot be controlled, that is, the user can direct or pop up the target webpage every time the user opens a browser or APP, which seriously affects the user experience.
Disclosure of Invention
Based on this, it is necessary to provide a method and a device for page redirection based on an HTTP request, so as to reduce the number of redirection times and optimize redirection efficiency, thereby improving the internet experience of a user.
In order to achieve the above purpose, the invention adopts the following technical scheme.
The invention firstly provides a page redirection method based on HTTP request, which comprises the following steps:
receiving an HTTP request;
judging whether a destination port of the HTTP request is TCP80, if so, executing the next step, otherwise, discarding the HTTP request message;
judging whether the HTTP request comes from a web browser, if so, executing the next step, and otherwise, discarding the HTTP request message;
judging whether the object of the HTTP request is a website, if so, executing the next step, otherwise, discarding the HTTP request message;
and redirecting the HTTP request.
In the above page redirection method, the step of determining whether the destination port of the HTTP request is TCP80 specifically includes:
and judging whether the method field in the HTTP request message is GET or not.
In the above method for redirecting a page, the step of determining whether the HTTP request is from a web browser specifically includes:
and judging whether the User-Agent field in the HTTP request message is the beginning of Mozilla.
In the above page redirection method, the step of determining whether the target of the HTTP request is a website specifically includes:
and intercepting a path field in the HTTP request message, and judging whether an object of the HTTP request is a website or not according to the path field.
In the above page redirection method, the step of determining whether the target of the HTTP request is a website specifically includes:
intercepting according to/by a strrchr function, and if the intercepted content ends in cs, png, txt, js or jpeg, judging that the HTTP request object is not a website.
In the above page redirection method, the step of redirecting the HTTP request specifically includes:
and judging whether multiple HTTP requests received within preset time are from the same host, if so, performing redirection action once within the preset time.
In the above page redirection method, the redirection is 302 redirection.
The invention also correspondingly provides a page redirection device based on the HTTP request, which comprises:
a receiving module, configured to receive an HTTP request;
the first judging module is used for judging whether a destination port of the HTTP request is TCP80, if so, executing the next step, and otherwise, discarding the HTTP request message;
the second judgment module is used for judging whether the HTTP request comes from a web browser, if so, executing the next step, and otherwise, discarding the HTTP request message;
the third judging module is used for judging whether the object of the HTTP request is a website, if so, executing the next step, and otherwise, discarding the HTTP request message;
and the redirection module is used for redirecting the HTTP request.
In the above-mentioned page redirection apparatus, the redirection module is specifically configured to:
and judging whether multiple HTTP requests received within preset time are from the same host, if so, performing redirection action once within the preset time.
In the above page redirection apparatus, the redirection is 302 redirection.
The invention judges whether the user needs to browse the webpage or not by verifying the message characteristics of the HTTP request, provides redirection service for the user in time, achieves the purpose of pushing advertisements, and does not redirect when the user requests other resources instead of websites on the Internet, thereby not bringing unnecessary interference to the user, not causing the user to generate negative emotion and effectively improving the use experience of the user.
Drawings
Fig. 1 is a schematic flowchart of page redirection based on HTTP request in this embodiment;
fig. 2 is a schematic structural diagram of a page resetting device based on an HTTP request in this embodiment.
The implementation of the objects of the present invention and their functions and principles will be further explained in the detailed description with reference to the attached drawings.
Detailed Description
The following further description is made with reference to the drawings and specific embodiments.
As shown in fig. 1, the present embodiment provides a page redirection method based on an HTTP request, which mainly includes the following steps:
s1: receiving an HTTP request;
s2: judging whether a destination port of the HTTP request is TCP80, if so, executing the next step, otherwise, discarding the HTTP request message;
s3: judging whether the HTTP request comes from a web browser, if so, executing the next step, and otherwise, discarding the HTTP request message;
s4: judging whether the object of the HTTP request is a website, if so, executing the next step, otherwise, discarding the HTTP request message;
s5: and redirecting the HTTP request.
The step S2 of determining whether the destination port of the HTTP request is TCP80 specifically includes:
and judging whether the method field in the HTTP request message is GET or not.
The content of the HTTP request message is assumed to contain the following codes:
“GET/HTTP/1.1
Host:www.youhuatech.com
Conntction:keep-alive
Upgrade-insecure-Requests:1
User-Agent:Mozilla/5.0(windows NT 6.1;win 64;x64)
……”。
line 1 of the above code is a method field with the initial character GET, indicating that the HTTP request is a web page request and the destination port is TCP 80. At this time, one condition for redirection is satisfied.
Then, the source of the HTTP request needs to be verified, and whether the HTTP request is from a web browser is determined, which specifically includes the steps of:
and judging whether the User-Agent field in the HTTP request message is the beginning of Mozilla.
Line 5 of the code above is the User-Agent field, with the initials Mozilla, indicating that the HTTP request came from a web browser, which now satisfies another condition for redirection.
The page redirection method of this embodiment also needs to satisfy another condition to perform redirection for the user, that is, the target of the HTTP request must be a website. The step of judging whether the object of the HTTP request is a website specifically includes:
and intercepting a path field in the HTTP request message, and judging whether an object of the HTTP request is a website or not according to the path field.
In line 1 of the above code, "HTTP" in "GET/HTTP/1.1" means that the GET object is a web site, so that it satisfies another condition of redirection.
Sometimes, the object of the HTTP request may be other resources outside the website, and how to determine the type of the object of the HTTP request may be implemented by the following method:
intercepting according to/by a strrchr function, and if the intercepted content ends with cs, png, txt, js or jpeg and the like, judging that the HTTP request object is not a website.
Wherein, the Strrchr function is a program of programming software in C language or similar C language, and is used for intercepting GET objects. For example, if line 1 of the above-mentioned code is "GET/css/style.css/1.1", or "GET/png/style.png/1.1", etc., it indicates that the object of the HTTP request is a resource file, and not a website.
If the HTTP request meets the three conditions, the HTTP request sent by the user can be redirected, and the purpose of pushing advertisements or other preset pages to the user is achieved.
A small amount of redirection can be accepted by the user in order to achieve both the desired effect and not to render the user objectionable. The present embodiment also optimizes the number of reorientations, for example, the step S5 is optimized as follows:
and judging whether multiple HTTP requests received within preset time are from the same host, if so, performing redirection action once within the preset time.
Therefore, if the HTTP requests meeting the three conditions come from the same host, the browsing websites are the same user, and at the moment, redirection is performed only once within a preset time (such as 1 minute) so as to reduce the redirection times, optimize the redirection efficiency and improve the user experience.
The redirection in this embodiment adopts a 302 redirection mode, which is also called temporary transfer (temporal moved) or temporary redirect (temporal redirect).
As shown in fig. 2, the present invention further provides a page redirection apparatus 100 based on HTTP request, which mainly includes:
a receiving module 10, configured to receive an HTTP request;
a first determining module 20, configured to determine whether a destination port of the HTTP request is TCP80, if so, execute the next step, otherwise, discard the HTTP request packet;
the second determination module 30 is configured to determine whether the HTTP request is from a web browser, if so, execute the next step, and otherwise, discard the HTTP request packet;
a third determining module 40, configured to determine whether an object of the HTTP request is a website, if so, execute the next step, otherwise, discard the HTTP request packet;
a redirection module 50, configured to redirect the HTTP request.
Wherein, the redirection module 50 is specifically configured to:
and judging whether multiple HTTP requests received within preset time are from the same host, if so, performing redirection action once within the preset time.
The redirection adopts a 302 redirection mode, which is also called temporal Moved or temporal redirect.
The functions, principles, and features of the page redirection apparatus 100 based on HTTP request in this embodiment are described above with reference to the embodiment shown in fig. 1, and are not described herein again.
In summary, the invention verifies the message characteristics of the HTTP request, determines whether the user needs to browse the web page, and provides the redirection service to the user in time, which not only achieves the purpose of pushing the advertisement, but also does not redirect when the user requests other resources other than the website, thereby not causing unnecessary interference to the user, not causing the user to feel dislike, and effectively improving the user experience.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention.

Claims (10)

1. A page redirection method based on HTTP request is characterized by comprising the following steps:
receiving an HTTP request;
judging whether a destination port of the HTTP request is TCP80, if so, executing the next step, otherwise, discarding the HTTP request message;
judging whether the HTTP request comes from a web browser, if so, executing the next step, and otherwise, discarding the HTTP request message;
judging whether the object of the HTTP request is a website, if so, executing the next step, otherwise, discarding the HTTP request message;
and redirecting the HTTP request.
2. The page redirection method according to claim 1, wherein said step of determining whether the destination port of the HTTP request is TCP80 specifically comprises:
and judging whether the method field in the HTTP request message is GET or not.
3. The page redirection method according to claim 1, wherein said step of determining whether the HTTP request is from a web browser specifically comprises:
and judging whether the User-Agent field in the HTTP request message is the beginning of Mozilla.
4. The method for redirecting pages as claimed in claim 1, wherein said step of determining whether the object of the HTTP request is a website specifically comprises:
and intercepting a path field in the HTTP request message, and judging whether an object of the HTTP request is a website or not according to the path field.
5. The method for redirecting pages as claimed in claim 4, wherein said step of determining whether the object of the HTTP request is a website specifically comprises:
intercepting according to/by a strrchr function, and if the intercepted content ends in cs, png, txt, js or jpeg, judging that the HTTP request object is not a website.
6. The page redirection method according to any of claims 1 to 5, wherein the step of redirecting the HTTP request specifically comprises:
and judging whether multiple HTTP requests received within preset time are from the same host, if so, performing redirection action once within the preset time.
7. The page redirection method according to claim 6, wherein the redirection is a 302 redirection.
8. An apparatus for redirecting a page based on an HTTP request, comprising:
a receiving module, configured to receive an HTTP request;
the first judging module is used for judging whether a destination port of the HTTP request is TCP80, if so, executing the next step, and otherwise, discarding the HTTP request message;
the second judgment module is used for judging whether the HTTP request comes from a web browser, if so, executing the next step, and otherwise, discarding the HTTP request message;
the third judging module is used for judging whether the object of the HTTP request is a website, if so, executing the next step, and otherwise, discarding the HTTP request message;
and the redirection module is used for redirecting the HTTP request.
9. The page redirection device according to claim 8, wherein said redirection module is specifically configured to:
and judging whether multiple HTTP requests received within preset time are from the same host, if so, performing redirection action once within the preset time.
10. The page redirection apparatus according to claim 9, wherein the redirection is a 302 redirection.
CN201911086479.4A 2019-11-08 2019-11-08 Page redirection method and device based on HTTP request Pending CN110879870A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911086479.4A CN110879870A (en) 2019-11-08 2019-11-08 Page redirection method and device based on HTTP request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911086479.4A CN110879870A (en) 2019-11-08 2019-11-08 Page redirection method and device based on HTTP request

Publications (1)

Publication Number Publication Date
CN110879870A true CN110879870A (en) 2020-03-13

Family

ID=69729024

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911086479.4A Pending CN110879870A (en) 2019-11-08 2019-11-08 Page redirection method and device based on HTTP request

Country Status (1)

Country Link
CN (1) CN110879870A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112235432A (en) * 2020-10-14 2021-01-15 深圳市友华软件科技有限公司 Method and device for supporting different networks to access label address
CN112689017A (en) * 2020-12-28 2021-04-20 咪咕文化科技有限公司 Redirection processing method and device, electronic equipment and storage medium
CN114791857A (en) * 2021-01-25 2022-07-26 青岛海信宽带多媒体技术有限公司 Control method and device for home gateway multi-core CPU (Central processing Unit)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102801795A (en) * 2012-08-03 2012-11-28 苏州迈科网络安全技术股份有限公司 Method and system for identifying and processing HTTP request
CN104123380A (en) * 2014-07-31 2014-10-29 珠海市君天电子科技有限公司 Webpage access method and device
CN106506675A (en) * 2016-11-25 2017-03-15 杭州华三通信技术有限公司 A kind of page reorientation method and device
CN107925685A (en) * 2015-07-31 2018-04-17 思杰系统有限公司 The redirector browsed for secure web-page
CN108259416A (en) * 2016-12-28 2018-07-06 华为技术有限公司 Detect the method and relevant device of malicious web pages

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102801795A (en) * 2012-08-03 2012-11-28 苏州迈科网络安全技术股份有限公司 Method and system for identifying and processing HTTP request
CN104123380A (en) * 2014-07-31 2014-10-29 珠海市君天电子科技有限公司 Webpage access method and device
CN107925685A (en) * 2015-07-31 2018-04-17 思杰系统有限公司 The redirector browsed for secure web-page
CN106506675A (en) * 2016-11-25 2017-03-15 杭州华三通信技术有限公司 A kind of page reorientation method and device
CN108259416A (en) * 2016-12-28 2018-07-06 华为技术有限公司 Detect the method and relevant device of malicious web pages

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112235432A (en) * 2020-10-14 2021-01-15 深圳市友华软件科技有限公司 Method and device for supporting different networks to access label address
CN112235432B (en) * 2020-10-14 2022-10-21 深圳市友华软件科技有限公司 Method and device for supporting different networks to access label address
CN112689017A (en) * 2020-12-28 2021-04-20 咪咕文化科技有限公司 Redirection processing method and device, electronic equipment and storage medium
CN114791857A (en) * 2021-01-25 2022-07-26 青岛海信宽带多媒体技术有限公司 Control method and device for home gateway multi-core CPU (Central processing Unit)

Similar Documents

Publication Publication Date Title
CN107025234B (en) Information pushing method and cache server
USRE45858E1 (en) System and method for modifying internet traffic and controlling search responses
US11159630B2 (en) Third party validation of web content
CN110879870A (en) Page redirection method and device based on HTTP request
US8085810B2 (en) Cross-layer pipelining optimizations for reduced roundtrips and improving quality of experience
EP2985705A2 (en) Webpage access method and apparatus, and router
US20100095220A1 (en) Methods and systems for providing a mini-webpage within a webpage
RU2630380C2 (en) System and advertising push method (push) based on home gateway
EP3002927A1 (en) Page redirection method, routing device, terminal device and system
WO2011029238A1 (en) Advertisement delivery method, advertisement server and advertisement system
US20110289138A1 (en) Method, machine and computer program product for sharing an application session across a plurality of domain names
US8327254B2 (en) Method and system for associating one or more contents with an electronic page
WO2011008145A1 (en) Providing content by using a social network
JP2019511788A (en) Routing method and apparatus
CN105991640A (en) Method for processing HTTP (hypertext transfer protocol) request and apparatus for processing HTTP (hypertext transfer protocol) request
US20160323365A1 (en) Content delivery method, apparatus, and system
WO2017020597A1 (en) Resource cache method and apparatus
US9729650B2 (en) Providing data to a network terminal
WO2012144919A2 (en) Methods and systems for access to real-time full-duplex web communications platforms
CN106789884A (en) A kind of portal authentication method and system
KR101131971B1 (en) System for advertizing through mobile terminal which provides function of full browsing internet access and method therefor
US20160020970A1 (en) Router and information-collection method thereof
Armstrong Just-In-Time Push Prefetching: Accelerating the Mobile Web
CN107295513B (en) Portal advertisement authentication method and system
EP3300335B1 (en) Device and method for data packet processing

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200313

RJ01 Rejection of invention patent application after publication