WordPress.org

Support

Support » WP-Advanced » Dynamic wordpress base URL for hostname

Dynamic wordpress base URL for hostname

  • Hi all,

    This question came about as a precursor to another question I have about silently switching themes based on hostname.

    I have a site configured to respond on a number of subdomains using the same wordpress installation, but I’d like to have all the links work relative to whatever the entry address is, rather than the original base url.

    If anyone has ideas how this can be achieved I’d appreciate it.

    Cheers.
    Matt

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi,

    i have the same problem.
    something that kind of works, is to modify the mysql options entry for “home” directory, when you use “/” all links are relative.
    but i got a problem with the admin area, some submissions lead to a 404 that way.

    what i’m trying now is writing a plugin hook to change the rendered absolute path based on my real server url.

    if you had any success please let me know.

    cheers, marc

    i found a solution:

    if you want to be able to run wordpress with different dynamic urls (aliases) linking to the same wordpress homedir, you can create a plugin with this function:

    function ml_clean_siteurl($url) {
    	$url="http://".$_SERVER[HTTP_HOST];
    	return $url;
    }
    add_filter('option_siteurl', 'ml_clean_siteurl');

    it tells wordpress to override the “siteurl” setting for internal links with the real server url.

    however, you should only do that if you’re using additional plugins to seperate content for each alias (e.g. different languages on different subdomains), otherwise google will see duplicate content (bad for ranking).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic wordpress base URL for hostname’ is closed to new replies.
Skip to toolbar