Advertisement
cw17s0n

redirect

Dec 17th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. add_action( 'template_redirect', 'https_redirect', 1 );
  2.     function https_redirect() {
  3.  
  4.             if ( is_page(array(188,186,253,257)) && ! is_ssl() ) {
  5.  
  6.                 if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
  7.                     wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']), 301 );
  8.                     exit();
  9.                 } else {
  10.                     wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
  11.                     exit();
  12.                 }
  13.             } else if ( !is_page(array(188,186,253,257)) && is_ssl() && !is_admin() ) {
  14.  
  15.                 if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
  16.                     wp_redirect(preg_replace('|^https://|', 'http://', $_SERVER['REQUEST_URI']), 301 );
  17.                     exit();
  18.                 } else {
  19.                     wp_redirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
  20.                     exit();
  21.                 }
  22.             }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement