Steps for redirecting from an IP address to a user's City
Jump to the user's City Based on the IP address to automatically identify the IP address, and jump to the city where the visitor is located
First go to the next latest pure IP database, and then perform the following operations:
1. Run showip.exe in the pure qq ip data library, click extract, and enter the file name, such as ip.txt. Then, you will get a TXT file.
2. Open ACCESS, tool-custom, command tab, and drag the import option to the toolbar above.
3. Create a database and a table with four fields
Startip type: Text (IP segment information of the relevant City)
Endip type: Text (IP address segment information of the relevant City)
Country type: Text (city name)
ReUrl type: text (the city path you want to jump to, such as: Beijing http://bj.abc.com)
4.click import button, select a file from the file list, find the ip.txt file that was just exported, and import it to the table just created ~
Converts a real IP address to a number. For example, the IP address range in Beijing is 1.1.0.0 -- 1.1.0.255.
Startip: 1*256*256*256 + 1*256*256 + 0*256 + 0 = 16842752 (This number is the final number to be put into the database)
Endip: 1*256*256*256 + 1*256*256 + 0*256 + 255 = 16843007 (This number is the final number to be placed in the database)
If you can use a program for batch processing, If You Don't Have Time (like me), you can directly go to the IP address library of the next dynamic network. It has already been processed. below is the program section:
User_ip = Request. ServerVariables ("REMOTE_ADDR") ''get the visitor's IP address
Userip_ary = split (user_ip ,".")
Tmp_userip = userip_ary (0) * 256*256*256 + userip_ary (1) * 256*256 + userip_ary (2) * 256 + userip_ary (3) ''convert the IP address to a number as required
'Identify the city where the user's IP belongs from the database
Set rs = Server. CreateObject ("ADODB. Recordset ")
SQL = "select * from ip where Startip <=" & tmp_userip & "and Endip> =" & tmp_userip
Rs. open SQL, conn, 1, 1
If rs. eof then
Response. redirect "index. asp" 'If the city is not found or the IP address cannot be identified, go to the home page. You can also specify the page
Else
Response. redirect rs ("ReUrl ")'
End if
Rs. close
Set rs = nothing
Place the above program on the default homepage of your VM! Or other pages (of course, you also need to set the default access to this file in the VM Control Panel) OK
Note: For more exciting tutorials, please follow the help houseDesign tutorialTopic,