[wp-trac] [WordPress Trac] #38273: HTTPS install is broken

WordPress Trac noreply at wordpress.org
Mon Oct 10 07:39:31 UTC 2016


#38273: HTTPS install is broken
-------------------------------+------------------------------
 Reporter:  yohgaki            |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Upgrade/Install    |     Version:  4.6.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by yohgaki):

 Thank you for your comment!!
 It turned out my wp-config.php was wrong.

 https://codex.wordpress.org/Administration_Over_SSL
 It says "Note: FORCE_SSL_ADMIN should be set before wp-settings.php is
 required.", but it does not state any other SSL related constant/vars must
 be defined before wp-settings.php.

 BAD - This only fixes redirect loop!
 {{{#!php
 <?php
 /** Sets up WordPress vars and included files. */
 require_once(ABSPATH . 'wp-settings.php');
 $_SERVER['HTTPS']='on'; // <<== Fix redirect loop, but it does NOT work.
 }}}

 GOOD
 {{{#!php
 <?php
 $_SERVER['HTTPS']='on';
 /** Sets up WordPress vars and included files. */
 require_once(ABSPATH . 'wp-settings.php');

 }}}

 I append additional config at the end of config file mostly. If BAD config
 didn't fix redirect loop, I might have noticed my mistake earlier. I think
 it may be good to mention this explicitly in the document, or better yet
 add comment that "wp-settings.php" should be included after additional
 var/constant definitions.

 For the record, working wp-config.php {{{# tail -n 30 wp-config.php}}} is:

 {{{#!php

 /**
  * For developers: WordPress debugging mode.
  *
  * Change this to true to enable the display of notices during
 development.
  * It is strongly recommended that plugin and theme developers use
 WP_DEBUG
  * in their development environments.
  */
 define('WP_DEBUG', false);

 /* That's all, stop editing! Happy blogging. */

 /** Absolute path to the WordPress directory. */
 if ( !defined('ABSPATH') )
         define('ABSPATH', dirname(__FILE__) . '/');

 /** SSL Support **/
 function isSecure() {
   if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
 $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
     $_SERVER['HTTPS'] = 'on';
     return TRUE;
   }
   return FALSE;
 }

 $web_site     = 'blog.ohgaki.net';
 $schema       = isSecure() ? 'https://' : 'http://';
 $web_site_url = $schema . $web_site;

 define('WP_HOME',    $web_site_url);
 define('WP_SITEURL', $web_site_url);

 /** Sets up WordPress vars and included files. */
 require_once(ABSPATH . 'wp-settings.php'); // <<== THIS MUST BE AT THE END
 OF wp-config.php

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38273#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list