I do not know whether you recently discovered a new phenomenon on the Internet, that is, some sites began to provide "username@server" virtual domain Name services. Because of the charm of "@", you may think: "If I can also provide this service, how good AH:) The popularity is certainly good! This article will give you the "@" of the "mystery" veil, so that everyone can come to "@"! (Do u @ today?)
Don't worry, this is not the e-mail address, is a virtual domain name, do not believe that the words can be accessed in the browser "bbs@zphp.com". Some friends should use the FTP function of IE, that is, in the address bar of the browser type "Password:username@server" IE will automatically log on to the FTP server, and in the Http1.1 protocol, the HTTP access authorization function, the same form as " Password:username@server ", where" password: "can be omitted, is also to access" bbs@zphp.com "is actually to the BBS as the identity of the access to" zphp.com "this server.
Then we just need to send a specific URI to the PHP program, in the database to search for a real URL redirection.
First we need to make a Transfer URI page (as the default document of the server, generally named index.htm), in the JS window object can implement this function, the following is the source code of index.htm:
The above code redirects the browser to gotourl.php and assigns the variable, querystring, to the current URI.
After successfully passing the URI to the PHP program, you can go to the database to find the real URL, the following is the SQL database corresponding table structure:
CREATE TABLE Domain (
ID int (3) UNSIGNED DEFAULT ' 0 ' not NULL, # domain ID
Domain char () not NULL, # domain name
Gotourl char (255) not NULL, # True URL
);
With the table set up, you can start writing gotourl.php, which is divided into three parts:
1. Analysis URL:
$url = Preg_replace ("/^http:///i", "", $url); Remove "/http" from the front of the URL, case-insensitive
$url = Preg_replace ("/@.+$/", "", $url); Remove the part after "@"
Then, the rest of the URLs will only contain the "username" section.
In order to apply to the database, most grateful characters need to be processed:
$url = Addslashes ($url);
2, search the real URL:
http://www.bkjia.com/PHPjc/445234.html www.bkjia.com true http://www.bkjia.com/PHPjc/445234.html techarticle I do not know whether you have recently discovered a new phenomenon on the Internet, that is, some sites began to provide username@server virtual Domain Services. Because of the charm of the @, we have to apply, you may want to ...