MyBB Community Forums

Full Version: Portal and Index as Subdomains?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there an easy way to do this?

Instead of www.website.com/portal.php, portal.website.com
Instead of www.website.com/index.php, forum.website.com

And so on?
well that's done through you hosting cpanel, isn't related to mybb.

regards
I can create the subdomains, but how do I have portal.website.com link to www.website.com/portal.php? Just forward the subdomain?
Yes, forwarding the subdomain should do it, but as Zaher said, this is a cpanel problem, not MyBB! Contact your host if you are confused!
As far as I know, you can not make subdomains on files. I might be wrong though.
Why don't you just make the subdomains redirect to the real page?

Otherwise, you can make a subdomain for your forum, and a subdomain for the portal via cPanel. Move the portal.php into the portal subdomain htdocs and edit portal.php where it says $forumdir = "./"; to something like "../forum/" (depends on your subdomain setup). Then rename portal.php to index.php.


You could use mod_rewrite if your server is Apache.
You can also use some PHP code like the following:
<?php
$domain = explode('.',sprintf($_SERVER['HTTP_HOST']));
$subdomain = strtolower(str_replace("http://", "", $domain[0]));
if ($subdomain != "www" and $subdomain != $domain[1])
{
    switch($subdomain) {
        case 'portal':
        $url = "portal.php";
        break;
        case 'index':
        $url = "index.php";
        break;
        case 'whatever':
        $url = "whateveryoumean.php";
        break;

        default:
        $url = "index.php";
    }
    header("location: ".$url); 
} else {
    header("location: index.php"); 
}
?>