Info
- 7 posts
- 3 voices
- Started 3 years ago by MikeLothar
- Latest reply from altimitmine
- This topic is not resolved
Several domains
-
- Posted 3 years ago #
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 "domainA.com". Now, when i get a visitor from "domainB.com", he will be redirected to "domainA.com" 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.
Mike
-
- Posted 3 years ago #
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]; } unset($matches); } 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 :)
-
- Posted 3 years ago #
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:
/var/www/vhosts/domaina.com/
/var/www/vhosts/domainb.com/You install bbPress in the domaina.com/ directory. In the domainb.com/ directory, you put an index.php file in there like this:
<?php header("Status: 301 Moved Permanently", false, 301); header("Location: http://www.domainA.com/"); exit(); ?>Then, when anyone accesses http://www.domainB.com/ they are seamlessly directed to http://www.domainA.com/. 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 domainB.com already out there, and you want to redirect them all to domainA.com.
-
- Posted 3 years ago #
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.
-
- Posted 3 years ago #
Ah, so when you said this "Now, when i get a visitor from "domainB.com", he will be redirected to "domainA.com" 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?
-
- Posted 3 years ago #
Exactly. :)
-
- Posted 2 years ago #
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/functions.bb-meta.php
2) Find this line:
case 'url': $option = 'uri';3) After it, add:
case 'uri': return "http://".$_SERVER['HTTP_HOST']."/forum/"; break;Replace the "/forum/" part with the proper URL to your forums. For example
http://blah.com/bbpress/
would be:
return "http://".$_SERVER['HTTP_HOST']."/bbpress/"; -
You must log in to post.