Skip to:

Several domains

  • mikelothar


    Hi, i hope someone can help me with this.

    I have several domains pointing to the same bbpress forum. For example, during the installation, i installed bbpress with the domain name setting of “”. Now, when i get a visitor from “”, he will be redirected to “” pretty fast, like when he’s clicking the “Home” link on the forum.

    I have managed to change this, by replacing, in the header file of the template, the:

    <?php bb_option('uri'); ?>

    .. to:

    http://<?php _e($_SERVER['HTTP_HOST']) ?>

    And it works. However, bbpress use the ‘uri’ alot, and for example, if the user is not logged in, and is trying to post, he will be redirected to domainA.

    What i’m asking for, i guess, is if it’s possible, in the php files somewhere, to specifically define the uri to be the server’http_host’ instead of the domainA? Where can i find and change this, and how?

    Thank you very much.


Viewing 6 replies - 1 through 6 (of 6 total)

  • mikelothar


    I’m assuming i have to change something here:

    // Set the URI and derivitaves
    if ( $bb->uri = bb_get_option('uri') ) {
    $bb->uri = rtrim($bb->uri, '/') . '/';

    // Not used in core anymore, only set here for plugin compatibility
    if ( preg_match( '@^(https?://[^/]+)((?:/.*)*/{1,1})$@i', $bb->uri, $matches ) ) {
    $bb->domain = $matches[1];
    $bb->path = $matches[2];
    } else {
    // Backwards compatibility
    // These were never set in the database
    if ( isset($bb->domain) ) {
    $bb->domain = rtrim( trim( $bb->domain ), '/' );
    if ( isset($bb->path) ) {
    $bb->path = trim($bb->path);
    if ( $bb->path != '/' ) $bb->path = '/' . trim($bb->path, '/') . '/';
    // We need both to build a uri
    if ( $bb->domain && $bb->path ) {
    $bb->uri = $bb->domain . $bb->path;

    If someone knows what exactly i need to change, please reply :)



    Why not redirect them with a permanent 301 redirect? If your host does not offer this, why not create a directory for each domain, like this:



    You install bbPress in the directory. In the directory, you put an index.php file in there like this:

    header("Status: 301 Moved Permanently", false, 301);


    Then, when anyone accesses they are seamlessly directed to Would that accomplish what you need?

    You can also use .htaccess for 301 redirects if there is more than one page, like there are search engine results with pages from already out there, and you want to redirect them all to



    Thanks for the reply. I think i didn’t explain myself too good.

    I want users who come from domainA to stay at domainA, and users from domainB to stay at domainB, and so on (got quite an amount of domains actually).

    I need bbPress to somehow get the domain from the browser, and use this domain instead of the one saved under the ‘uri’ or ‘BB_HOST’ variable.



    Ah, so when you said this “Now, when i get a visitor from “”, he will be redirected to “” pretty fast, like when he’s clicking the “Home” link on the forum.” this is NOT want you want, eh? You want multiple domains/URLs all pointing to the same bbPress installation and people to stay on the domain they came in from?



    Exactly. :)



    I know this is old but I needed it to, so here is the answer for anyone else finding this on google:

    1) Open bb-includes/

    2) Find this line:

    case 'url':
    $option = 'uri';

    3) After it, add:

    case 'uri':
    return "http://".$_SERVER['HTTP_HOST']."/forum/";

    Replace the “/forum/” part with the proper URL to your forums. For example

    would be:

    return "http://".$_SERVER['HTTP_HOST']."/bbpress/";

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar