Clippings

  • Redirect domain to subfolder

    Posted Oct 2nd, 2006 in Clippings With | 11 Comments

    Last night I was looking for a way to redirect a domain (example.com) to example.com/folder but without actually redirecting the user to that folder.

    So I thought that the best way to go about is actually treading every request as example.com/folder.

    Anyway enough said here is the result.

    /*
     * Redirect to a different folder of the current domain that was requested
     */
    $host = $_SERVER['HTTP_HOST'];
    $extra = '~ckr';
    header("Location: http://$host/$extra");
    exit;
    

    Pretty need isn’t it? It only took 4 lines.

Constantinos Koloumrbis 2004-2013 ©