这是我的vhost。
<VirtualHost *:80>
ServerName mywebsite
ServerAdmin mywebsite@mail.com
DocumentRoot /var/www
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
<VirtualHost *:443>
ServerName mywebsite
ServerAdmin mywebsite@mail.com
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www>
Options +FollowSymlinks
AllowOverride all
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www
SetEnv HTTP_HOME /var/www
Satisfy Any
</Directory>
#ssl protocol
Protocols h2 http/1.1
SSLHonorCipherOrder on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
SSLCertificateFile cert
SSLCertificateKeyFile cert2
SSLCertificateChainFile cert3
</VirtualHost>
此条件将所有http请求重定向到https。 例如 http://domine/wordpress到https://domine/wordpress 要么 123.123.123.123/wordpress to https://123.123.123.123/wordpress
我需要帮助才能将ip请求重定向到domine, 例如
123.123.123.123/wordpress to https://domine/wordpress 要么 https://123.123.123.123/wordpress至https://domine/wordpress
答案 0 :(得分:0)
由于您只有一个域名,最简单的方法是使用一个规则重定向所有域名:
RewriteRule ^(.*)$ https://mywebsite%{REQUEST_URI} [L,R=301]