Apache2.4.9 多域名多网站配置
1:先打开Apache目录下的配置文件httpd.conf(在conf目录下),找到#Include conf/extra/httpd-vhosts.conf这句,将之前的#号去掉,开启虚拟主机配置。
2:在conf/extra/httpd-vhosts.conf中进行虚拟主机的配置操作;也可以在httpd.conf直接写入配置,但是不建议这么做;尽量做到配置分离,解耦。在文件中添加以下示例配置:
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/"
ServerName bbs.tuling.com
<Directory "D:/wamp/www/">
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
ServreName为域名名称DocumentRoot为网站目录
Apache 2.4 多站点配置记录
基于域名的虚拟主机配置
<VirtualHost *:80>
DocumentRoot /var/www/cms
ServerName www.example.com
RewriteEngine On
RewriteCond %{REQUEST_METHOR} ^TRACE
RewriteRule .* - [F]
<Directory "/var/www/cms">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
ErrorLog "/var/www/log/httpd/example-com-error.log"
CustomLog "/var/www//log/httpd/example-com.log" common
</VirtualHost>
将 example.com 自动跳转到 www.example.com
<VirtualHost *:80>
ServerName example.com
RedirectMatch permanent ^/(.*) http://www.example.com/$1
</VirtualHost>
Apache 的详细介绍:请点这里
Apache 的下载地址:请点这里