Create EE2.0 site on sub-domain


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // 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.  
  3. // 2. Update your .htaccess file to include the following:
  4.  
  5. RewriteCond %{HTTP_HOST} ^mysubdomain.mydomain.com [NC]
  6. RewriteCond %{REQUEST_FILENAME} !foldericreatedinstep1/
  7. RewriteRule ^(.*)$ foldericreatedinstep1/$1 [L]
  8.  
  9. // 3. Copy your root index.php file into the sub-domain folder created in step 1
  10.  
  11. // 4. Open the root index.php and edit the CUSTOM CONFIG VALUES to look like this:
  12.  
  13. $assign_to_config['global_vars'] = array(
  14. "pv_site_version"=>"full"
  15. );
  16.  
  17. $assign_to_config['site_url'] = 'http://www.mydomain.com';
  18.  
  19. // 5. Open the index.php file in your sub-domain and edit the CUSTOM CONFIG VALUES to look like this:
  20.  
  21. $system_path = 'var/www/system'; // Make sure you edit the relative path to your system folder here.
  22.  
  23. $assign_to_config['global_vars'] = array(
  24. "pv_site_version"=>"mobile"
  25. );
  26.  
  27. $assign_to_config['site_url'] = 'http://m.mydomain.com';
  28.  
  29. // 6. Now all you need to do in your templates is use something like this:
  30.  
  31. {if pv_site_version == "full"}
  32. {embed="mygroup/full_template"}
  33. {if:else}
  34. {embed="mygroup/mobile_template"}
  35. {/if}
  36.  
  37.  
  38. // 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.
  39.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.