Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Can a sub-domain point to an App?

edited June 2013 in Framework

Well.. I guess the title kinda explains it...

I'm wondering if there is a way to have an option for a sub-domain to point to an app, like, instead of having the /blog/whatever after it.


would be equivalent to:

I don't think there is... but I'm more on the question of is/will it be possible? Maybe having it on a per app basis by way of conf.php?


  • You'll have to make sure the subdomain is an alias in the site's virtual host, then you should be able to do this by creating a bootstrap.php file in your site root with something like the following:

    // Prepend subdomain to path if it's present and not www.
    $dom = explode ('.', $_SERVER['HTTP_HOST']);
    if (count ($dom) > 2) {
        $sub = array_shift ($dom);
        if ($sub !== 'www') {
            $_SERVER['REQUEST_URI'] = '/' . $sub . $_SERVER['REQUEST_URI'];

    Elefant will load this file automatically just before the page request is processed.

    You could also modify it to check if $sub is in a specific list of valid subdomains, or even map different subdomains to any app using an associative array.

Sign In or Register to comment.