WordPress.org

Ready to get started?Download WordPress

Forums

get wordpress running on both https / http (6 posts)

  1. startx
    Member
    Posted 8 years ago #

    hello.

    is there any way of setting up a wordpress install (2.0) making it possible to access the site via a http AND a https vhost.

    maybe it is a fault or misunderstanding the installatioan procedure, but if i access an installed site via https all links are still pointing to http and images seem to be included with full http-path as well. is there a way/hack whatever to use only relative URLs so it works?

    i do not mean the ssl hack for the admin area, i mean simply accessing the site.

    thx,
    startx.

  2. Kafkaesqui

    Posted 8 years ago #

    Well, there's:

    http://www.almosteffortless.com/wordpress/force-ssl/

    which comes close to what you're asking for. I've been plugging away at a method of forcing WordPress to use relative links (for such things as this), but hit a number of roadblocks. Let's just say WordPress is pretty demanding for "absolute" control on this issue.

  3. startx
    Member
    Posted 8 years ago #

    i cannot believe that wordpress is totally bound to full path URLs. is there any reason for that?

  4. trevorturk
    Member
    Posted 8 years ago #

    I'm not sure why WordPress uses absolute URLs, but the plugin I made (linked above) would FORCE a client to connect via https. If you have an SSL certificate, you already have a site that allows http AND https connections. Right?

  5. startx
    Member
    Posted 8 years ago #

    hi trevorturk.

    sure the plugin works, but i actually dont want to use "force https" because i guess its quite confusing to users. i was hoping for a more "basic" solution to the problem.

    i found somewhere that http/https was allready on the wishlist for 1.6 but it seems it was never worked on that.
    correct me if im wrong.

  6. faifai
    Member
    Posted 8 years ago #

    I have do some "ugly" modified in the file "wp-includes\function.php".
    I have changed the get_settings function to the following(I have mark with the comment '//------HERE IS THE CODE I HAVE CHANGED START--------' line), and seem is what you need, hope this can help!

    function get_settings($setting) {
    global $wpdb;

    $value = wp_cache_get($setting, 'options');

    if ( false === $value ) {
    if ( defined('WP_INSTALLING') )
    $wpdb->hide_errors();
    $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1");
    if ( defined('WP_INSTALLING') )
    $wpdb->show_errors();

    if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
    $value = $row->option_value;
    wp_cache_set($setting, $value, 'options');
    } else {
    return false;
    }
    }

    // If home is not set use siteurl.
    if ( 'home' == $setting && '' == $value )
    return get_settings('siteurl');

    //------HERE IS THE CODE I HAVE CHANGED START--------

    if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting ){
    $value = preg_replace('|/+$|', '', $value);

    if($_SERVER["HTTPS"] == "on") {
    $value = preg_replace('|http://|', 'https://', $value);
    }
    }
    //------HERE IS THE CODE I HAVE CHANGED END--------

    return apply_filters( 'option_' . $setting, maybe_unserialize($value) );
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags