Apache:虚拟主机:修订间差异
imported>Soleverlee 以“在/etc/httpd/conf.d中新建一个conf文件 <source lang="bash"> <VirtualHost *:80> ServerAdmin dr@riguz.com DocumentRoot "/home/webapp/chanzhieps/www"...”为内容创建页面 |
imported>Soleverlee 无编辑摘要 |
||
第28行: | 第28行: | ||
</VirtualHost> | </VirtualHost> | ||
</source> | </source> | ||
其中AllowOverride all配置允许使用.htaccess进行域名重写。如果要定向http到https,可以: | |||
<source lang="bash"> | |||
<VirtualHost *:80> | |||
... | |||
RewriteEngine On | |||
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] | |||
RewriteCond %{HTTPS} off | |||
... | |||
</VirtualHost> | |||
</source> | |||
[[Category:Linux/Unix]] | [[Category:Linux/Unix]] |
2016年11月23日 (三) 03:24的最新版本
在/etc/httpd/conf.d中新建一个conf文件
<VirtualHost *:80>
ServerAdmin dr@riguz.com
DocumentRoot "/home/webapp/chanzhieps/www"
ServerName dr.riguz.com
ServerAlias www.dr.riguz.com
ErrorLog "logs/chanzhi.log"
CustomLog "logs/chanzhi.log" common
<Directory "/home/webapp/chanzhieps/www">
Require all granted
</Directory>
</VirtualHost>
如果是wiki,可以再加一个配置文件
<VirtualHost *:80>
ServerAdmin dr@riguz.com
DocumentRoot "/home/webapp/wiki"
ServerName wiki.riguz.com
ServerAlias www.wiki.riguz.com
ErrorLog "logs/wiki.log"
CustomLog "logs/wiki.log" common
<Directory "/home/webapp/wiki">
Require all granted
AllowOverride all
</Directory>
</VirtualHost>
其中AllowOverride all配置允许使用.htaccess进行域名重写。如果要定向http到https,可以:
<VirtualHost *:80>
...
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
RewriteCond %{HTTPS} off
...
</VirtualHost>