• I have changed this:

    wp_redirect( esc_url_raw( 'https://' . $_SERVER['SERVER_NAME'] . '/' . $_SERVER['REQUEST_URI'] ), 301 );

    To this:
    wp_redirect( esc_url_raw( 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ), 301 );

    Because the URL it created contained double slash.

    Example https://www.domain.com//contact.

    So after removing '/' from the url it works fine.

    From PHP docs I understand that REQUEST_URI already contains the slash:

    https://es.php.net/manual/en/reserved.variables.server.php
    ‘REQUEST_URI’
    The URI which was given in order to access this page; for instance, ‘/index.html’.

  • The topic ‘Fix in the url generated for redirect, remove extra ‘/’’ is closed to new replies.