第一步:打开apache的配置文件httpd.conf,去掉LoadModule rewrite_module modules/mod_rewrite.so前面的#号。
第二步:打配置文件尾部加上
RewriteEngine on
RewriteMap lowercase int:tolower
#定义映像文件
RewriteMap vhost txt:/apache/vhost/vhost.map
#处理变名
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+) $
这里做基于文件的重新映射
RewriteCond ${vhost:%1} ^(/.) $
RewriteRule ^/(.) $ %1/ $1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+) $
RewriteCond ${vhost:%1} ^(/.) $
RewriteRule ^/(.) $ %1/cgi-bin/ $1
注意:vhost.map文件是域名和空间映像的文件,格式如下:
www.abc.com /vhostusr/www.abc.com
www.xyz.com /vhostuser/www.xyz.com
www.cccbbbb.net /vhostuser/www.ccbbbb.net
.
.
.
.
(你不会连/vhostuser/www.abc.com目录也没建吧,会报错的哟)
第三步:保存配置文件,重启apache。在开设可绑定域名的空间时,只要在vhost.map文件里添加相应记录,并建立相应文件夹就OK了~~~
其实这个可以用php脚本来完成的,很简单的~~呵呵~~~
注意啊:php_admin_value open_basedir “path",这个选项要配好啊~~新手如果不懂的,就不要动这个了~
贴一个简单的vhost.map文件的操作代码。。。随意写的,,,
1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4<meta content="text/css" http-equiv="Content-Style-Type"/>
5<link href="index.cgi" rel="top" title=""/>
6<link href="search.php" rel="search" title=""/>
7<link href="faq.php" rel="help" title=""/>
8<link href="memberlist.php" rel="author" title=""/>
9<title>注册 - youname.sun126.com</title>
10<style type="text/css">
11<!--
12body {
13background-color: #FFFFFF;
14scrollbar-face-color: #DEE3E7;
15scrollbar-highlight-color: #FFFFFF;
16scrollbar-shadow-color: #DEE3E7;
17scrollbar-3dlight-color: #D1D7DC;
18scrollbar-arrow-color: #;
19scrollbar-track-color: #EFEFEF;
20scrollbar-darkshadow-color: #98AAB1;
21}
22font,th,td,p { font-family: 'song',Verdana }
23a:link,a:active,a:visited { color : #; }
24a:hover { text-decoration: underline; color : #DD6900; }
25hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
26.bodyline { background-color: #FFFFFF; border: 1px #98AAB1 solid; }
27.forumline { background-color: #000000; border: 0px #9898ba solid; }
28td.row1 { background-color: #f0f3fa; }
29td.row2 { background-color: #fafbfc; }
30td.row3 { background-color: #D1D7DC; }
31td.rowpic {
32background-color: #D1D9E2;
33background-repeat: repeat-y;
34}
35th {
36color: #333333; font-size: 12px; font-weight : bold;
37background-color: #9898BA; height: 25px;
38
39td.cat,td.catHead,td.catSides,td.catLeft,td.catRight,td.catBottom {
40background-color:#d1d9e2; border: #9898ba; border-style: solid; height: 28px;
41}
42
43td.cat,td.catHead,td.catBottom {
44height: 29px;
45border-width: 0px 0px 0px 0px;
46}
47th.thHead,th.thSides,th.thTop,th.thLeft,th.thRight,th.thBottom,th.thCornerL,th.thCornerR {
48font-weight: bold; border: #FFFFFF; border-style: solid; height: 28px;
49}
50td.row3Right,td.spaceRow {
51background-color: #D1D7DC; border: #9898ba; border-style: solid;
52}
53
54th.thHead,td.catHead { font-size: 13px; border-width: 1px 1px 0px 1px; }
55th.thSides,td.catSides,td.spaceRow { border-width: 0px 1px 0px 1px; }
56th.thRight,td.catRight,td.row3Right { border-width: 0px 1px 0px 0px; }
57th.thLeft,td.catLeft { border-width: 0px 0px 0px 1px; }
58th.thBottom,td.catBottom { border-width: 0px 1px 1px 1px; }
59th.thTop { border-width: 1px 0px 0px 0px; }
60th.thCornerL { border-width: 1px 0px 0px 1px; }
61th.thCornerR { border-width: 1px 1px 0px 0px; }
62.maintitle {
63font-weight: bold; font-size: 22px; font-family: "'song',Verdana",'song',Verdana;
64text-decoration: none; line-height : 120%; color : #;
65}
66.gen { font-size : 13px; }
67.genmed { font-size : 12px; }
68.gensmall { font-size : 12px; }
69.gen,.genmed,.gensmall { color : #; }
70a.gen,a.genmed,a.gensmall { color: #; text-decoration: none; }
71a.gen:hover,a.genmed:hover,a.gensmall:hover { color: #DD6900; text-decoration: underline; }
72
73/* The register, login, search etc links at the top of the page */
74.mainmenu { font-size : 12px; color : # }
75a.mainmenu { text-decoration: none; color : #; }
76a.mainmenu:hover{ text-decoration: underline; color : #DD6900; }
77
78/* Forum category titles */
79.cattitle { font-weight: bold; font-size: 13px ; letter-spacing: 1px; color : #}
80a.cattitle { text-decoration: none; color : #; }
81a.cattitle:hover{ text-decoration: underline; }
82
83/* Forum title: Text and link to the forums used in: index.cgi */
84.forumlink { font-weight: bold; font-size: 13px; color : #; }
85a.forumlink { text-decoration: none; color : #; }
86a.forumlink:hover{ text-decoration: underline; color : #DD6900; }
87
88/* Used for the navigation text, (Page 1,2,3 etc) and the navigation bar when in a forum */
89.nav { font-weight: bold; font-size: 12px; color : #;}
90a.nav { text-decoration: none; color : #; }
91a.nav:hover { text-decoration: underline; }
92
93/* titles for the topics: could specify viewed link colour too */
94.topictitle {font-size: 12px; color : #; }
95h1,h2 { font-weight: bold; font-size: 12px; color : #; }
96a.topictitle:link { text-decoration: none; color : #; }
97a.topictitle:visited { text-decoration: none; color : #333333; }
98a.topictitle:hover { text-decoration: underline; color : #DD6900; }
99
100/* Name of poster in viewmsg.php and viewtopic.php and other places */
101.name { font-size : 12px; color : #;}
102
103/* Location, number of posts, post date etc */
104.postdetails { font-size : 12px; color : #; }
105
106/* The content of the posts (body of text) */
107.postbody { font-size : 13px; line-height: 18px}
108a.postlink:link { text-decoration: none; color : # }
109a.postlink:visited { text-decoration: none; color : #333333; }
110a.postlink:hover { text-decoration: underline; color : #DD6900}
111
112/* Quote & Code blocks */
113.code {
114font-family: 'song',Verdana; font-size: 12px; color: #006600;
115background-color: #FAFAFA; border: #D1D7DC; border-style: solid;
116border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px
117}
118
119.quote {
120font-family: 'song',Verdana; font-size: 12px; color: #444444; line-height: 125%;
121background-color: #FAFAFA; border: #D1D7DC; border-style: solid;
122border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px
123}
124
125/* Copyright and bottom info */
126.copyright { font-size: 12px; font-family: 'song',Verdana; color: #444444; letter-spacing: -1px;}
127a.copyright { color: #444444; text-decoration: none;}
128a.copyright:hover { color: #; text-decoration: underline;}
129
130/* Form elements */
131input,textarea, select {
132color : #;
133font: normal 12px 'song',Verdana;
134border-color : #;
135}
136
137/* The text input fields background colour */
138input.post, textarea.post, select {
139background-color : #FFFFFF;
140}
141
142input { text-indent : 2px; }
143
144/* The buttons used for bbCode styling in message post */
145input.button {
146background-color : #EFEFEF;
147color : #;
148font-size: 12px; font-family: 'song',Verdana;
149}
150
151/* The main submit button option */
152input.mainoption {
153background-color : #FAFAFA;
154font-weight : bold;
155}
156
157/* None-bold submit button */
158input.liteoption {
159background-color : #FAFAFA;
160font-weight : normal;
161}
162\-->
163</style>
164</head>
165<body bgcolor="#FFFFFF" link="#" text="#" vlink="#333333"></body>
166<a name="top"></a>
167<!--栏目条-->
168<style type="text/css">
169A.title1:link {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}
170A.title1:visited {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}
171A.title1:active {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}
172A.title1:hover {font-size:17.9px;font-family:arial;font-weight:bold;text-decoration:none;color:#ffffff;}
173A.title2:link {text-decoration:none;color:#000000;font-size:12px}
174A.title2:visited {text-decoration:none;color:#000000;font-size:12px}
175A.title2:active {text-decoration:none;color:#ff0000;font-size:12px}
176A.title2:hover {text-decoration:none;color:#ff0000;font-size:12px}
177</style>
if (empty( $HTTP_POST_VARS[reg])) {
1<form action="<?= $PHP_SELF?>" enctype="multipart/form-data" method="post">
2<table align="center" border="0" cellpadding="3" cellspacing="1" class="forumline" width="95%">
3<tr>
4<th class="thHead" colspan="2" height="25" valign="middle"> <a href="http://www.sun126.com">精彩奇讯科技虚拟主机自助申请系统</a> 请填写注册信息</th>
5</tr>
6<tr>
7<td class="row2" colspan="2"><span class="gensmall">请输入在本服务器新增的域名:</span></td>
8</tr>
9<tr>
10<td class="row1" width="20%"><span class="gen">域名名称: http://</span></td>
11<td class="row2"><input class="post" maxlength="25" name="domain" size="10" style="width:100px" type="text"/><span class="gen"><font color="red">.sun126.com</font></span></td>
12</tr>
13<tr>
14<td align="center" class="row1" colspan="2" height="28">
15<input class="post" maxlength="14" name="dateformat" type="hidden" value="Y-m-d H:m">
16<input name="reg" type="hidden" value="1"/><input class="mainoption" name="submit" type="submit" value="发送"/> <input class="liteoption" name="reset" type="reset" value="重设"/></input></td>
17</tr>
18</table>
19</form>
20
21
22</html>
1 }
1
2
3
4if ( $HTTP_POST_VARS[reg]) {
5for( $i=0; $i<9; $i++){
6$char1=chr(rand(97,122));
7$chara.= $char1;
8}
9$domain = $HTTP_POST_VARS[domain] . ".sun126.com /" . $HTTP_POST_VARS[domain];
10// 检查并创建目录开始*******************************
11if (is_dir('d:/vhostuser/user_'. $chara.'_'. $HTTP_POST_VARS[domain])) {
12$domain = "http://" . $domain;
13echo "
<table align="center" border='"0"' cellpadding='"3"' cellspacing='"1"' class='"forumline"' width='"95%"'><tr> <td class='"row2"' colspan='"2"'><span class='"gensmall"'>此域名已经使用,请更换~~<a href="$PHP_SELF">返回</a></span></td> </tr> <tr> <td class='"row2"' colspan='"2"'><span class='"gensmall"'> <a href="$domain" target="_blank"><font color="BLUE"><u>点击查看已开空间</u></font></a></span></td> </tr></table>
1";
2exit;
3} else {
4mkdir('d:/vhostuser/user_'. $chara.'_'. $HTTP_POST_VARS[domain]);
5}
6
7$HTTP_POST_VARS[reg] = "0";
8$domain = "http://" . $domain;
9echo "
<table align="center" border='"0"' cellpadding='"3"' cellspacing='"1"' class='"forumline"' width='"95%"'><tr> <td class='"row2"' colspan='"2"'><span class='"gensmall"'>空间开设成空!~~<a href="$PHP_SELF">返回</a></span><span class='"gensmall"'> <a href="$domain" target="_blank"><font color="BLUE">点击查看已开空间</font></a> <a href="http://www.sun126.com">< 联系我们 - 精彩奇讯科技></a> </span></td> </tr></table>
1";
2}
3