Add the following code to the httpd. conf file of apache:
The code is as follows: |
Copy code |
<VirtualHost *: 80> DocumentRoot/var/html/blog.111cn.net/ ServerName 111cn.net ServerAlias * .111cn.net DirectoryIndex index.html index. php
RewriteEngine on RewriteCond % {HTTP_HOST} ^ [a-zA-Z0-9] + .blog.sjzycxx.cn $ RewriteRule ^ /? $/% {HTTP_HOST} RewriteRule ^/[a-zA-Z0-9] +) .blog.sjzycxx.cn /? $/Index. php? User = $1 </VirtualHost> |
Note: After the above configuration is complete, we still need to perform simple processing on the php program.
The code is as follows: |
Copy code |
<? Php $ Url_this = $ _ SERVER ['http _ host']; $ Url_this = str_replace ("www.", "", $ url_this ); $ Url_this = str_replace (".111cn.net", "", $ url_this ); $ Url_this = str_replace ("'", "", $ url_this ); $ Url_this = str_replace ("@", "", $ url_this ); $ Url_this = str_replace ("=", "", $ url_this ); $ Url_this = str_replace (";", "", $ url_this ); ?> |
Now I use $ url_this to search the database for user information bound to a specified user's second-level domain name.