Owen
Owen

Reputation: 790

Codeigniter setup for subdomains sharing one template


I’m quite new to CI but have lots of experience with PHP and I wanting to know the best way to setup CI for subdomains and template sharing.

Basically what I want to have is several subdomain all running off one CI install so they can share a common template. Each subdomain website will be different from each other with their own pages and functions.
Logging in across the subdomains is not a requirement, but I’d like to keep my options open.

What is the best way of going about doing this?
Thanks,
Owen

Upvotes: 0

Views: 445

Answers (2)

shikhar
shikhar

Reputation: 2469

This is the approach you should take.

  1. Have the installation at xyz.com
  2. All requests with subdomain should be rewritten with the help of .htaccess
    Eg d1.xyz.com should be rewritten to xyz.com/?customer=d1
  3. You can in your script use the get variable d1 to do the manipulations with templates

Upvotes: 0

Phil Sturgeon
Phil Sturgeon

Reputation: 30766

By templates do you just mean view files or do you mean actual Template library specific views? If you use my Template library you can configure the locations of theme folders, but as for view files that is more difficult.

Packages in CI 2.0 support the sharing of various files like models, helpers, libraries, etc but this does not support view files. This is an upcoming feature that might make it into 2.0.1 depending on the release schedule, but for now you'll have to create a symlink in one directory to link to another.

Upvotes: 1

Related Questions