• I installed wordpress on my domain and i selected “choose protocol” as https://

    Now, i realised i need https://www. and not https://

    I do not want to delete wordpress and reinstall everything.

    Is there a solution for this?

    Please dont tell me not to do this. I have to do it.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think if you edited your .htaccess file and included the following code, you’ll force it to use www. for your website (replace the https://www.example.com with your website):

    #Force www:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    You could do that, but if the DNS for both www and non-www point to the same WordPress installation and your web server is configured to send both versions to the same WordPress installation, then you just need to update your WordPress URL to the www version.

    When WordPress gets the non-www version is should sort it out for you.

    I think there is more than one way to do what you need, and this is the one I used near the top of wp-config.php:

    <?php
    /**
    * The base configurations of the WordPress.
    *
    * @package WordPress
    */
    /*-either-*/
    /** @ root/wp-config.php: /*toggle on/off*
    define('WP_HOME','https://domain.com');
    define('WP_SITEURL','https://domain.com');
    /*-or-*/
    /** @ root/wp-config.php: /*toggle on/off*
    define('WP_HOME','https://www.domain.com');
    define('WP_SITEURL','https://www.domain.com');
    /*-end-*/

    Adding a single slash to make /** @ root/wp-config.php: /*toggle on/off* look like /** @ root/wp-config.php: /*toggle on/off*/ will turn either pair of lines on, then go back and disable that after refreshing your browser a few times, and then go to Dashboard > Settings > General and save the results you see there.

    If this might seem easier, I think this can do the same from the top of functions.php in your theme:

    <?php
    /*-either-*/
    /* @ theme/functions.php /*toggle on/off*
    update_option('siteurl','https://domain.com');
    update_option('home','https://domain.com');
    /*-or-*/
    /* @ theme/functions.php /*toggle on/off*
    update_option('siteurl','https://www.domain.com');
    update_option('home','https://www.domain.com');
    /*-end-*/

    Here is a related article that is definitely worth reading, imo:
    https://www.internetmarketingninjas.com/blog/search-engine-optimization/301-redirects/

    And for a local opinion on the matter:
    https://www.ads-software.com/support/topic/i-think-bulletproof-just-stopped-me-from-damaging-my-own-site?replies=40#post-6233626

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how do i change domain installtion from (without www. to with www.) in wordpress’ is closed to new replies.