目标:输入i-hua.cc的域名自动跳转到https://www.hua.cc
最简便方法是在域名控制台做别名,如果没有域名控制权就使用下面方法了。
在目前网站根目录下新建目录123,创建自动跳转配置文件
mkdir /data/home/123
[root@localhost 123]# vi .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^i-hua.cc$ [NC]
RewriteRule ^(.*)$ https://www.hua.cc/$1 [L,R=301]
http方式访问添加虚拟主机
[root@localhost 123]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /data/home/123
ServerName www.ihua.cc:80
</VirtualHost>
https加密方式访问添加虚拟主机
[root@localhost 123]# vi /usr/local/apache/conf/extra/httpd-ssl.conf
<VirtualHost *:443>
DocumentRoot "/data/home/123"
ServerName www.i-hua.cc:443
SSLEngine on
SSLCertificateFile "/usr/local/ca/server.crt"
SSLCertificateKeyFile "/usr/local/ca/server.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/usr/local/apache/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>