admin管理员组文章数量:1314585
I want to redirect when our website is on HTTP to HTTPS: I wrote a function but it is not working. please help me.
public function add_header(){
if($this->current_domain == "http://". $this->domain || $this->current_domain == "https://". $this->domain){
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO']=="https"){
return true;
} elseif (isset($_SERVER['HTTPS'])) {
$this->redirect = get_option('ssl-redirect-check');
if ( 'on' === strtolower( $_SERVER['HTTPS'] && strpos( home_url(), 'https' ) == false )) {
$ssl_url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"];
wp_redirect($ssl_url, 301);
exit();
}
if ( '1' == $_SERVER['HTTPS'] ) {
$ssl_url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"];
wp_redirect($ssl_url, 301);
exit();
}
} else {
if ($this->redirect == "yes"){
$ssl_url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"];
wp_redirect($ssl_url, 301);
exit();
}
}
} else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: ". $this->current_domain . $this->uri );
die();
}
}
本文标签: phpssl redirect function is not working
版权声明:本文标题:php - ssl redirect function is not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741963306a2407407.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论