ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Default template for "Classic" method for running multiple domains on EE2

August 08, 2010 12:41pm

Subscribe [3]
  • #1 / Aug 08, 2010 12:41pm

    Tim Jukes

    13 posts

    Has anyone had any luck with creating a site across more than one domain in EE2 using the ‘classic’ method as outlined in this wiki entry?

    I’ve tried updating the index.php file that I’ve copied to the home folder of my alternative domain and can get everything working correctly apart from the default template which seems to be overriding everything

    $assign_to_config['site_url'] = 'http://new-top-level-domain.com';
    $assign_to_config['template_group'] = 'new_template_group';
    $assign_to_config['template'] = 'new_index';

    No matter what ‘tempate_group/template’ combination I enter, the page always spits out the ‘new_template_group/new_index’ page.

    Anyone have any ideas? Thanks!

    ps. I’m on the latest build - 20100805

  • #2 / Sep 15, 2010 9:28am

    GDmac - expocom

    350 posts

    Allthough EE 2.1 doesn’t have a path.php, some of the site-specific variables can be set in index.php. I had the same problem with setting up a subdomain that uses a different homepage (a different default template_group/template).

    There does seem to be an issue with the config settings, because, as soon as you enter the [‘template_group’] and [‘template’] in index.php, it overrules everything. It even overrides the $assign_to_config[‘site_404’] = ‘group/template’ that you’ve might have set in index.php. Here’s somewhat of a work-around.

    in the main directory have the basic htaccess file to remove index.php from the URI like before, but we add a section before that, that points everything for the subdomain to its own subdirectory:

    RewriteEngine On
    RewriteBase /
    # the [L] means if it matches, it's the last rule,
    # any other rules for the subdomain go into 
    # the htaccess in that subdirectory
    RewriteCond %{HTTP_HOST} example2.com
    RewriteCond %{REQUEST_URI} !^/example2dir
    RewriteRule ^(.*)$ example2dir/$1 [L]
    # remove index.php for main domain
    # only if requested file or dir does not exist
    # don't forget to make EE handle 404 (template manager)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

    In the htaccess for the subdirectory catch empty requests (^$), and substitute the wanted template-group.

    RewriteEngine On
    # RewriteBase /example2dir/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    RewriteRule ^$ index.php?/wanted_template_group/index [L]

    In the copy of index.php in the subdirectory, also make sure to set the “./system” variable . Set the other assign_config variables but leave template stuff empty.

    $assign_to_config['template_group'] = '';
    $assign_to_config['template'] = '';
    $assign_to_config['site_index'] = 'http://www.example2.com';
    $assign_to_config['site_404'] = 'siteparts/404';

    success,
    GDmac

    (ps. i will test this a bit more and will update this post)

  • #3 / Oct 04, 2010 4:39am

    James Mattison

    8 posts

    GDmac, this is a great tip, can I check a few things with you (bear with me, I’m a newbie)

    If my domain name is ‘jamesmattison.co.uk’ and the subdomain I want to use for my alternative site version is called ‘iblog’ is this the correct set-up for the htaccess file?

    RewriteEngine On
    RewriteBase /
    # the [L] means if it matches, it's the last rule,
    # any other rules for the subdomain go into 
    # the htaccess in that subdirectory
    RewriteCond %{HTTP_HOST} jamesmattison.co.uk
    RewriteCond %{REQUEST_URI} !^/iblog
    RewriteRule ^(.*)$ iblog/$1 [L]
    # remove index.php for main domain
    # only if requested file or dir does not exist
    # don't forget to make EE handle 404 (template manager)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

    I’ve never had much luck in removing the index.php from my page addresses, can I remove this section of the .htaccess file if it causes problems without affecting the rest of the functionality?


    My subdomain template group would be called ‘iblog’. This would be the .htaccess file placed in my subdomain directory:

    RewriteEngine On
    # RewriteBase /example2dir/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    RewriteRule ^$ index.php?/iblog/index [L]


    The variables changed in my index.php file copied into the iblog subdomain directory, with the correct path to my 404 error page:

    $assign_to_config['template_group'] = '';
    $assign_to_config['template'] = '';
    $assign_to_config['site_index'] = 'http://www.jamesmattison.co.uk';
    $assign_to_config['site_404'] = 'error/404.html';
  • #4 / Oct 04, 2010 6:32am

    James Mattison

    8 posts

    Just tried this and encountered a problem:

    I have a main domain: http://www.jamesmattison.co.uk and a subdomain: iblog.jamesmattison.co.uk

    Using the settings I listed above, when I visit either of these subdomains (or even if I visit http://jamesmattison.co.uk) the .htaccess file is sending everything to the iblog index template.

    Any ideas why?


    UPDATE*

    If I remove the custom .htaccess file from the root directory and replace the old version, everything seems to work ok. Wish I knew why.

  • #5 / Oct 04, 2010 2:17pm

    GDmac - expocom

    350 posts

    James, allmost. the part where you check for the subdomain, you should also enter the subdomain to check for : - )

    RewriteCond %{HTTP_HOST} iblog.jamesmattison.co.uk
    RewriteCond %{REQUEST_URI} !^/iblog
    RewriteRule ^(.*)$ iblog/$1 [L]

    line1. is the requested hostname iblog.example.com?
    line2. is the uri NOT a subdirectory called iblog (i.e. accessing example.com/iblog directly)
    line3. then load deferred the uri stuff from directory iblog/request-uri

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases