判官007 发表于 2017-1-9 12:08:11

apache中配置二级域名的两种方式

关于apache下配置的两种方式:
第一种:在httd.conf文件中做台下配置
步骤如下:
   1). 将VirtrualHostName 80 前面的注释去掉
   2).添加你的二级域名(有多少个加多少个)
   
<VirtualHost *:80>
ServerName tt.domain.com
ServerAlias tt.domain.com
DocumentRoot "/var/www/games"
<Directory "/var/www/games">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.shtml index.aspx default.aspx
AllowOverride All
Order Deny,Allow
Allow from all
php_admin_value open_basedir "/var/www/games;/var/tmp/uploadtemp/;/tmp"
php_admin_value safe_mode On
</Directory>
</VirtualHost>


第二种 通过rewrite方式,这种方式不用重启apache,推荐使用
步骤如下:
1). 在某目录下如/usr/local/apache2下新建一个文件,名为vhost.map
2). 在vhost.map中添加你的二级域名对应的目录
       格式如下
   
admin.domain.com/var/www/games/admin

3).在httpd.conf里添加rewrite 语法如下:
      
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost txt:vhost.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1

OK以上就是apache中配置二级域名的方式,ngninx类似
页: [1]
查看完整版本: apache中配置二级域名的两种方式