Return to Snippet

Revision: 27918
at June 26, 2010 23:08 by phil7085


Initial Code
// 1. Create a sub-domain. Using Engine Hosting it is simply a case of creating a new folder in the root (public_html) directory.

// 2. Update your .htaccess file to include the following:

RewriteCond %{HTTP_HOST} ^mysubdomain.mydomain.com [NC]
RewriteCond %{REQUEST_FILENAME} !foldericreatedinstep1/
RewriteRule ^(.*)$ foldericreatedinstep1/$1 [L] 

// 3. Copy your root index.php file into the sub-domain folder created in step 1

// 4. Open the root index.php and edit the CUSTOM CONFIG VALUES to look like this:

$assign_to_config['global_vars'] = array(
	"pv_site_version"=>"full"
);

$assign_to_config['site_url'] = 'http://www.mydomain.com';

// 5. Open the index.php file in your sub-domain and edit the CUSTOM CONFIG VALUES to look like this:

$system_path = 'var/www/system'; // Make sure you edit the relative path to your system folder here.

$assign_to_config['global_vars'] = array(
	"pv_site_version"=>"mobile"
);

$assign_to_config['site_url'] = 'http://m.mydomain.com';

// 6. Now all you need to do in your templates is use something like this:

{if pv_site_version == "full"}
{embed="mygroup/full_template"}
{if:else}
{embed="mygroup/mobile_template"}
{/if}


// NOTES: The reason I have also edited the site_url variable in both templates is so that using {path=""} still works. Otherwise when on the mobile version the url to a link will render it as www. and not m.

Initial URL

                                

Initial Description

                                

Initial Title
Create EE2.0 site on sub-domain

Initial Tags
mobile

Initial Language
PHP