Welcome Guest, Not a member yet? Register   Sign In
Check if at root domain
#1

[eluser]Dauntless[/eluser]
Hi,

Sorry for the bad title. My situation is as follows:

A website must have 2 'sub parts': Sales & Rent. The website is divided through sales.yyy.com and rent.yyy.com. Both urls should refer to the same directory on the server (the main directory, yyy.com). I then check if the user is at rent or sales and display the correct content accordingly.

I currently use preg_match to check for the sub domain, but I also need a way to see if the user is at yyy.com (without sub domain, or on a different sub domain than rent or sales). I want to display a splash screen letting the user choose between rent & sales.

How could I check if I'm at yyy.com. I suspect I could also do this with preg_match, but I'm hoping there's a better way ?

Thanks!
#2

[eluser]TheFuzzy0ne[/eluser]
You could probably do it with an .htaccess file.
#3

[eluser]Dauntless[/eluser]
I have absolutely no experience with htaccess, so a little more help would be nice Smile
#4

[eluser]jedd[/eluser]
Dauntless - can you please clarify. You have this site already, or you are about to build it? If you have it already and just want to identify where you are, so to speak, have you tried querying your standard PHP/HTTP variables?

I can see some pain having two different domain names pointing at the same codebase. Is it possible to use instead xyz.com/rent/... and xyz.com/sales/... (if you're 'about to build' only, of course).
#5

[eluser]Dauntless[/eluser]
That's exactly the problem, the site has already been built. As it is now, you have 'companysales.com' and 'companyrent.com'. They want it merged using the system that's running on companysales.com (CI)

I was told on this forum that it would probably be best if I used subdomains that would link to the same folder.

Both sites will of course look 99% alike, with only the content being different.
#6

[eluser]jedd[/eluser]
Okay. Gotcha.
[quote author="Dauntless" date="1236034316"]
I was told on this forum that it would probably be best if I used subdomains that would link to the same folder.
[/quote]

Gurus lurk and will answer this with more clarity - but my gut feeling is that it's gonna get messy, because if they're sharing the same config.php file, then they're going to have to have the same base_url.

You can probably get around this with rewrites and/or some funky apache config / htaccess (though the latter would leave you exposed to the base_url problem I think).

Oh, unless you're talking about hosting them as separate applications within the one CI instance? This is documented in the user_guide - have you read this page: [url="http://ellislab.com/codeigniter/user-guide/general/managing_apps.html"]http://ellislab.com/codeigniter/user-guide/general/managing_apps.html[/url]

I think that with that, or with multiple CI instances, you might still have some issues if your code is written to talk to the DB as though no one else is talking to it.
#7

[eluser]Dauntless[/eluser]
Are you saying it's going to get messy because my links (which are based on base_url) will force the user to go to www.xyz.com/zyx in stead of sales.xyz.com/zyx or rent.xyz.com/zyx ?
#8

[eluser]jedd[/eluser]
Quote:Are you saying it’s going to get messy because my links (which are based on base_url) will force the user to go to www.xyz.com/zyx in stead of sales.xyz.com/zyx or rent.xyz.com/zyx ?

I'm just saying .. it could get very messy. Wink

Any minute now, someone who knows what they're doing will pop into this thread. In the interim, it might help if you can further clarify what your end game is, and what flexibility you have in getting there.

Quote:As it is now, you have 'companysales.com' and 'companyrent.com'. They want it merged using the system that's running on companysales.com (CI)

So the two systems right now - they run separate codebases, using separate databases, on (effectively) separate web servers, yes? Are either / both developed to run in CI already?

What's the motivator behind 'wanting it merged' - and is there some flexibility with how that's done and what it looks like (from a URL point of view) after the fact?

I'm confused because CI is inexpensive to run, and you can have lots of them on a single server. And there's no obvious benefit from integrating different systems like this, at least from a CI point of view, if they weren't written to be integrated in the first place. Unless you want to start sharing code .. in which case, you might want to run them as two (or more) controller trees within a single CI instance. In that scenario you could do rewrites and some apache magic (I guess) to make it look like what you want it to look like. </speculation>

But it still doesn't seem to be the most elegant solution to a slightly fuzzy problem.
#9

[eluser]Dauntless[/eluser]
The companysales.com site is running a CI website, fully functional.
The companyrent.com site is running a different website + database. The website can be dismissed and the database will be migrated together with the companysales.com database. (With productType = 1 for sales & productType = 0 for rent, or something like that)

And I want to share ALL code. The website is completely the same, just the products differ.

If it's still not clear, do say so and I will do my best to clarify even further Smile
#10

[eluser]Dauntless[/eluser]
Any other suggestions ?

(Is it also maybe possible to overwrite base_path from my controller? This would also solve a few bugs)




Theme © iAndrew 2016 - Forum software by © MyBB