用mod_rewrite轻松实现多用户二级域名
在httpd.conf中,对某个主机进行以下操作:
<VirtualHost _default_:80>
ServerAdmin yourmail@domain.com
DocumentRoot /YourWwwRoot/.default
ServerName all-sites
ErrorLog logs/all-sites-error_log
CustomLog logs/all-sites-access_log common
# 下面实现动态解析
Rewriteengine on
RewriteCond %{HTTP_HOST} ^[a-z0-9\-]+\.gaojinbo\.com$
RewriteRule ^/(.*)$ /%{SERVER_NAME}/$1 ##注##
RewriteRule ^/([a-z0-9\-]+)\.gaojinbo\.com/(.*)$ /YourWwwRoot/$1/$2 [L]
# 没有解析到的情况下扔到自己的一个PHP中做一下处理
RewriteRule ^.*$ /index.php [L]
</VirtualHost>
接着在DNS中开设一个泛解析到对应的IP地址。
就可以实现下面的方案。
* 域名:gaojinbo.com
* 绝对路径:/home/domain.com/
* www.domain.com 自动解析到 /home/gaojinbo.com/www/
* abc.domain.com 自动解析到 /home/gaojinbo.com/abc/
* 等等子域名都可以自动解析到 /home/gaojinbo.com/对应子域名名称的文件夹
直接建立子域名名称的文件夹即可使用。不需重启apache。
九月 8th, 2011 at 08:37
You should check this out……
[...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well [...]………
九月 25th, 2011 at 10:17
Check this out……
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]………