Viewing 5 replies - 1 through 5 (of 5 total)
  • have you tried using this one?
    Function Reference/get site url

    Thread Starter grisales

    (@grisales)

    Hello faospark!.

    Actually I did but it doesn’t futfil my purposes.

    Happens that I’m using url rewrites to map a domain and with all of the other functions I got the rewritten url but there is one case where I need to generate the real url (underneath) in a string replacement.

    WP Functions I used that return the rewritten URL

    get_bloginfo('url');
    bloginfo('url');
    get_site_url();
    site_url();
    get_home_url();
    home_url();

    WP Functions that return the real URL

    network_site_url();
    network_home_url();

    This is the portion of my script currently

    str_replace( 'https://www.mywebsite.com/wordpress/', '', $thumbnail["thumb"] );

    But I was looking for something more like

    str_replace( network_site_url(), '', $thumbnail["thumb"] );

    And according to the document of the function network_site_url() in the codex , this should return the string as I need but is not doing it, not even adding the parameters $path and/or $scheme.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Happens that I’m using url rewrites to map a domain

    Why not just change the site URLs?

    https://halfelf.org/2014/mapping-domains-without-plugin/

    Thread Starter grisales

    (@grisales)

    Hello Ipstenu!.

    Thank you for your suggestion.

    It would be the rigth choice if the site was in live mode but unfortunately wouldn’t work in this case because as a staging environment the website has to serve with the same install two different ambients simultaneously.

    1st ambient (local): This ambient uses anydomainname.dev as domain in a local VPS with several other local websites, make the domain change to anydomain.com would represent changes not only in wordpress but also in the database server, the dns server and the web server without mention how it would affect other people in the localnetwork tied to this tld as well everytime the domain has to be changed just to open it to the web.

    2nd ambient (web): This ambient simply uses a tunnel created with “ngrok” which help to avoid the long tail process of open a door trough the router and changing IPTables in the proxy server, etc, etc, etc.

    So bottom line… not an option in this case.
    Due to the way the development environment has been set up it is required to use this method.

    But hey, I appreciate your help and also would like to thank you for sharing your post, gave me an interesting insight for future references! ??

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    It would be the rigth choice if the site was in live mode but unfortunately wouldn’t work in this case because as a staging environment the website has to serve with the same install two different ambients simultaneously.

    Ouch. WordPress absolutely hates you with that one. I mean, it’s a general WP thing: It does not like to serve two URLs like that. Never has.

    The bug you reference is not really a bug, it’s just Multisite saying that it knows domain.com and domain.com/wordpress are the same thing, when you’re giving WP it’s own directory (i.e. install it in domain.com/wordpress, access from domain.com). That doesn’t sound like what you’re doing since you’re fully changing the domains.

    Also, network_site_url template tag retrieves the site url for the “main” site of the current network with the appropriate protocol. So that’s acting as expected too ??

    Perhaps tossing this in wp-config.php would fix it?

    if ( $_SERVER["HTTP_HOST"] == "anydomainname.dev" ) { 
    
    define('WP_SITEURL', 'https://anydomainname.dev');
    define('WP_HOME', 'https://anydomainname.dev');
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wrong output from network_site_url on multisite’ is closed to new replies.