x
 
Create New Page

Revision: Running Multiple Domains or Subdomains or Subsites

Revision from: 08:35, 15 Jan 2008

Please Note: This is the “classic” method for running multiple sites and sub-domains and is community supported. If you want to run the officially support method for multiple Sites from a single installation of ExpressionEnigne, consider the Multiple Site Manager as it has numerous benefits over this technique.

It is possible to run ExpressionEngine so that content can be accessed from more than one location. This is often desired if you want to put different content on different subdomains or simply otherwise want to access your content through more than one location.
In order to allow this, you simply need to follow a few steps:

Copy index.php and path.php

You must place a copy of the main site path.php and index.php (the ones from your main directory, not from the system directory) files into the directory from which you wish to access ExpressionEngine.
The directory you specify must be able to have files within it be able to access your main installation system directory. You should ensure you don’t have any “open_basedir” or other restrictions in place which could prevent this.
If you want, you may rename the index.php file as described on the Renaming Main Site File page.

Edit path.php

Once you’ve copied the files, you must open path.php to edit it.

$system_path

First, you must ensure that the $system_path variable is set correctly within the file. The variable should contain a relative path from the current directory (in which the path.php file resides) to your site’s system directory. For instance:

$system_path = "../system/";

Add New Variables

Second, you must add several new variables to the file:

$template_group = "template_group_name";
$template = "template_name";
$site_url = "http://www.example.com/subdirectory/";
$site_index = "index.php";
$site_404 = "template_group_name/template_name";

The variables are:

$template_group The name of the Template Group you want to be shown by default.
$template The name of the Template that you want to be shown by default.
$site_url The full URL to the current directory in which this path.php file resides.
$site_index This is an optional variable that will let you indicate the name of the index file if you change the name of index.php to something else.
$site_404 This is an optional variable that will allow you to set a specific Template to display as a 404 page for your subsite. This will override the general site setting for this subsite.

Optional Variables

You may specify a PHP array containing “global variables” that will be available only to Templates accessed through that path.php file.

$global_vars = array(); // This array must be associative

For instance, let’s say you want to define a weblog name and a Template Group name. You could use this:
$global_vars = array(
"my_weblog" => "news",
"my_template_group" => "display"
); // Last entry must not include the comma at the end

Within your Templates, you would then be able to use the {my_weblog} and {my_template_group} variables.

Successful index.php hiding

This is a common practice, if not an official one.  The result is not seeing ‘index.php’ anywhere in your urls, provided you make the arrangements properly.

A warning should be given which respects the official position, that if you make a mistake in the setup for removing index.php, the results can be quite confusing to troubleshoot.  If you have that problem using the instructions, simply delete or rename all new .htaccess files you have constructed, and prior operation of your site should resume. 

With that caveat and fixup out of the way, let’s see a way index.php removal can be done, including smooth operation on subdomains.

The actual method you choose for hiding should come from here, as the ins and outs are discussed:  Remove index.php From URLs

Probably the first method described in the removal article is best, especially if you are concerned about search engine optimization (SEO), as discussed with the second.

The result of each of the methods is that you will have an .htaccess file added, or lines added to the one you already have, for a basic EE site.

The trick to make index.php hiding work smoothly with multiple or subdomains is to also have an .htaccess file with the same index.php hiding rules in each of your new multiple or subdomain root folders, where the copied index.php and modified path.php are.

If you already prefer another index.php removal method on your main site, you can try replicating those rules into your new site’s .htaccess instead, and see if they will do the job as well.

...

 

Category:Tricks

Categories: