Question about WordPress site URL settings and SSL


  • | 871 points

    I updated Laragon and noticed that a new bit is added to the wp-config.php file when using the quick app to create a WordPress site:

    if ( !defined('WP_CLI') ) {
    define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] );
    define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] );
    }

    A result of this is that the ability to change the site URL in the WordPress admin is disabled. Here is a screenshot showing those settings as grayed out:

    https://cl.ly/0165b015baaa

    Is there a setting not to include those extra lines?

    I see that this will serve the site based on the request URL to either HTTP or HTTPS. I'm thinking it would be good if I always use the same protocol because WordPress stores uploaded images, internal links, etc in the database based on the URL so it should be consistent.

    When I setup Laragon to use SSL in the preference by enabling the Port and through the Apache SSL menu items, then I have the option for SSL, but the WWW menu links to the sites always go to them using HTTP. Is there an option for those to always use HTTPS instead?

    Thank you for any insight and suggestions.


  • administrators
    | 109549 points

    Hi @dmccan
    Please see my answers below:

    1. The settings help us to deal with different protocols and it is very useful when you need to share projects using Ngrok.
    2. You can change setting in Virtual Host template in usr\tpl to auto redirect port 80 to 443.
      I will create a tutorial on this if needeed.

  • | 871 points

    @leokhoa said in Question about WordPress site URL settings and SSL:

    auto redirect port 80 to 443

    @leokhoa, Thank you for the suggestion. I've modified the first section of the VirtualHost.tpl file to look like this, and new sites created do go to SSL. Is this what you were thinking?

    <VirtualHost *:<<PORT>>>
    DocumentRoot "${ROOT}"
    ServerName ${SITE}
    Redirect / https://${SITE}
    ServerAlias *.${SITE}
    <Directory "${ROOT}">
    AllowOverride All
    Require all granted
    </Directory>
    </VirtualHost>

    Thank you,

    David


  • administrators
    | 109549 points

    @dmccan : That's right!

    If you want the setting to be applied to all, just clean all auto Virtual Hosts: Menu > Apache > sites-enabled > Delete all [auto.]


  • | 871 points

    @leokhoa - Thank you for confirming I am on the right track. :heart:


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.