RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
或者仅仅是一页
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} directory
RewriteRule ^(.*)$ https://www.example.com/directory/$1 [R,L]
或者您可以将此php添加到特定文件
if (!isset($_SERVER[\'HTTPS\']) || !$_SERVER[\'HTTPS\']) { // if request is not secure, redirect to secure url
$url = \'https://\' . $_SERVER[\'HTTP_HOST\']
. $_SERVER[\'REQUEST_URI\'];
header(\'Location: \' . $url);
exit;
}
或者将wordpress重写规则与SSL规则相结合。。
RewriteRule ^(.*)$ https://www.example.com/directory/index\\.php[R,L]