apache重定向www.b.com到https://www.a.com
配置ssl:
- NameVirtualHost *:443
- DocumentRoot /usr/local/webapps
- ServerName www.a.com
- ErrorLog /var/log/httpd/ssl_error_log
- TransferLog /var/log/httpd/ssl_access_log
- SSLEngine on
- SSLCertificateFile /etc/pki/tls/certs/a.com.crt
- SSLCertificateKeyFile /etc/pki/tls/private/a.key
- NameVirtualHost *:80
- DocumentRoot /usr/local/webapps/
- ServerName www.a.com
- ErrorLog /var/log/httpd/error.log
- TransferLog /var/log/httpd/access_log
- RewriteEngine on
- RewriteCond %{HTTPS} off
- RewriteRule (.*) https://%{SERVER_NAME}:443%{REQUEST_URI}
配置重定向:
- ServerName www.b.com
- Redirect permanent / https://www.a.com
- ErrorLog logs/error_log
- CustomLog logs/access_log common
开始的时候重定向一直有问题,访问www.b.com时没有跳转到https://www.a.com,并且页面提示证书错误,后来检查发现没有开NameVirtualHost *:80这个参数,以前的版本中,不开这个参数语法检查是会报错的,但新版本中只会有警告信息,所以一直没有注意到,打开这个参数以后跳转就没有问题了。
稍后补充ssl详细配置。
转载于:https://blog.51cto.com/itianjing/1020016