Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Subdomains
#1

[eluser]Maglok[/eluser]
Hey all,

I have a growing webapp that is installed on: test.domain.com

The life version is at www.domain.com.

I have two subdomains (mabye even more) that have the same site, but with a different skin. Let's call them sub1.domain.com and sub2.domain.com. This poses problems in CI. As far as I can see there is no classes or anything that can help me with shuffling domains.

Underwater the domains are actually subdirs of the main dir. So sub1.domain.com is the same as www.domain.com/sub1.

Any tips or ideas how I would go about working with this? I have CI installed in the root. I need that CI to cover all the subdomains.

Mabye I need to extend the site_url() function with an additional parameter or something of the likes. Regardless I am pretty stumped.
#2

[eluser]rogierb[/eluser]
Structure:

-www
---index.php
---subdomain
------index.php
---subdomain
------index.php
-system
-application

If you add a variable to index.php with the skin you want, your done.
All the index.php reference the same application directory.

Don't know is this is what you are looking for, but hope it helps :-)

Edit: Don't forget the .htaccess with RewriteBase in de subdirs.
#3

[eluser]brianw1975[/eluser]
[quote author="Maglok" date="1266358250"]Hey all,

I have a growing webapp that is installed on: test.domain.com

The life version is at www.domain.com.

I have two subdomains (mabye even more) that have the same site, but with a different skin. Let's call them sub1.domain.com and sub2.domain.com. This poses problems in CI. As far as I can see there is no classes or anything that can help me with shuffling domains.

Underwater the domains are actually subdirs of the main dir. So sub1.domain.com is the same as www.domain.com/sub1.

Any tips or ideas how I would go about working with this? I have CI installed in the root. I need that CI to cover all the subdomains.

Mabye I need to extend the site_url() function with an additional parameter or something of the likes. Regardless I am pretty stumped.[/quote]

You really need to rethink the whole subdomain use in this instance. You are totally killing your own SEO scores because of duplicate content.
#4

[eluser]Maglok[/eluser]
@Rogierb: So have several CI 'entrances' so to speak? Hmm...

@Brianw1975: Could you explain why that would be the case? Since the subsite uses the same layout the content is of course very different. The test domain is also excluded with a robots.txt. I don't see why anything would count as duplicate content? Mabye cause it might scan a dir and then get there again through the subdomain? If so how do I deal with that then?
#5

[eluser]rogierb[/eluser]
Yes, based on your entrance you can set/get the data you need. You would still have the same application directory and thuss the same functionality but the different entrance allows you to treat it as a different application/domain/site
#6

[eluser]Maglok[/eluser]
Well that works. I can use index.php's to port to the main application. But index.php is before CI launches basically right? Then how would I parse like a 'load in this subsite template' variable?

Basically for each subsite I have a different footer/header. The main view file is the same like so:

Code:
<?php $this->load->view('site1_header'); ?>
<!-- Do stuff -->
<?php $this->load->view('site1_footer'); ?>

I'd have to add like a variable to it kinda like this:

Code:
<?php $this->load->view($site . "_header'); ?>
<!-- Do stuff -->
<?php $this->load->view($site . "_footer'); ?>

My issue being how do I grab that from index.php?

EDIT: And I just noticed it doesnt take the subdomain as the site_url, so any links generated with site_url('page') will still link to the main domain and not the subdomain.
#7

[eluser]rogierb[/eluser]
Define 2 constants in your index.php
1: the template you want to use
2: the base_url or subdomain

Then edit config.php to use that constant in the config.php base_url
Code:
$config['base_url']    = "http://".(defined(MY_CONSTANT))?MY_CONSTANT:"").$_SERVER['SERVER_NAME']."/";

or something like that.

The same applies to the view files.
#8

[eluser]brianw1975[/eluser]
[quote author="Maglok" date="1266417390"]@Rogierb: So have several CI 'entrances' so to speak? Hmm...

@Brianw1975: Could you explain why that would be the case? Since the subsite uses the same layout the content is of course very different. The test domain is also excluded with a robots.txt. I don't see why anything would count as duplicate content? Mabye cause it might scan a dir and then get there again through the subdomain? If so how do I deal with that then?[/quote]

Ah, see, here is confusion, in your OP you said:

Quote:I have two subdomains (mabye even more) that have the same site, but with a different skin.

To me this says: same content, different colors/layout.
#9

[eluser]Maglok[/eluser]
@Rogierb: I see now, I should be able to get that working. Thanks.

@Brianw1975: My bad, you are right I was being rather ambigous at best there. Though I do wonder now if I get duplicate content problems. Google will be able to scan the www.domain.com/sub1 and sub1.domain.com and get the same thing. How does that work I wonder.
#10

[eluser]brianw1975[/eluser]
[quote author="Maglok" date="1266433929"]@Rogierb: I see now, I should be able to get that working. Thanks.

@Brianw1975: My bad, you are right I was being rather ambigous at best there. Though I do wonder now if I get duplicate content problems. Google will be able to scan the www.domain.com/sub1 and sub1.domain.com and get the same thing. How does that work I wonder.[/quote]

I would use robots.txt to block all search engines in that place(s)(while in development) and in production use .htaccess to redirect site.com/sub1 to sub1.site.com with a permanent (302) redirect if they aren't coming from the subdomain




Theme © iAndrew 2016 - Forum software by © MyBB