Welcome Guest, Not a member yet? Register   Sign In
sub-domain as variable
#1

[eluser]banjomacman[/eluser]
I have a very simple site consisting of only 7 pages. I would like use sub-domains to control the variable stuff on those seven pages.

Example:
doctors.simplesite.com
lawyers.simplesite.com
dentist.simplesite.com

As mentioned for each of those 3 sub-domains I will only be making minor content/color changes. I'm trying to figure out foremost if using an .htaccess file will allow me to have something like the following.

doctors.simplesite.com/page1
doctors.simplesite.com/page2
doctors.simplesite.com/page3

lawyers.simplesite.com/page1
lawyers.simplesite.com/page2

I would prefer not to redirect to simplesite.com/index.php/doctors/step1 which is all I've managed to do.

Can anyone suggest what I would need in my .htaccess file and if I should approach it using 1 controller with a method for each sub-domain or each sub-domain has a controller and the page# be the methods?

I'm not sure if this matters but my hosting company seems to create a sub-folder in public-html for each sub-domain.
#2

[eluser]systemsos[/eluser]
Have your host put your subdomains pointing to the same place as your main application's index.html (normally just /public_html/) or have them add a wildcard (all sub-domains) to that web directory.

Using PHP you can find out the host used to access the page with the variable $_SERVER['HTTP_HOST'] (which is PHP specific).

I haven't written anything up but I believe from memory that HTTP_HOST returns things like www.mydomain.com or subdomain.mydomain.com or mydomain.com (if not www is placed). You'd have to write a tiny bit of code to tidy that up and return what the domain is not including the www. at the start (as some people tend to put www.subdomain.mydomain.com which is normally legal as far as apache is concerned) and everything up to the mydomain.com (as you can have subdomains that are subdomains of themselves sub1.sub2.mydomain.com)

Let me know your thoughts.
#3

[eluser]banjomacman[/eluser]
okay. I think your suggestion will work. Let me describe what I did and what's happening. If anyone sees a problem please let me know.

I pointed the doctors sub-domain to the public_html folder and now it seems like anything after the domain name is expected to be a controller. So back to my simple 7 page theme site. I will have a controller for each page. Page1, Page2, etc. and then use $_SERVER[’HTTP_HOST’] to know which theme to use. I will work on it this weekend to see if I run into any problems.

Does anyone see or know what my the value of my $config['base_url'] variable should be? Should I just assign it after I parse the sub-domain using $_SERVER[’HTTP_HOST’]. Thanks for the help so far.
#4

[eluser]systemsos[/eluser]
Um - yes. That sounds like a the best idea. Wasn't what I had in mind but it sounds very good.

Smile Good work on sorting it Smile




Theme © iAndrew 2016 - Forum software by © MyBB