Welcome Guest, Not a member yet? Register   Sign In
A record to virtual host to specific controller/page?
#1

[eluser]rogierb[/eluser]
His guys 'n gals,

We have an application that can be accessed through different domain names or subdomains via virtual hosts and A records. Sow far no problem since they all land on the welcome controller/root

Now we need a domain/subdomain but route it to a specific controller or URI. I have no idea how to do this or even if it is possible.

So basically I want www.domain.com and www.anotherdomein.com to go to /var/www/domain_root and special.domain.com to /var/www/domain/root/special (where special is a controller )

Even better if I could set something like http://www.domain.com/special/8/34 or http://www.domain.com/another_controller/8/34


Any thoughts on how to accomplish this?

thanx,
Rogier
#2

[eluser]TheFuzzy0ne[/eluser]
I would suggest doing it via an htaccess file. How? I don't know... I've been defeated many-a-time by htaccess, but I'm happy to help you experiment in getting it right.

How many domains are we talking about here? Have you considered running each domain as a separate app (although that might not be possible)? The reason I ask, is that you're going to have to do some magic to get functions like base_url() to work as expected, whereas if each domain/app has it's own configuration, things might be a little more straight-forward.
#3

[eluser]rogierb[/eluser]
The problem is that is has te be one app and database. Just for some users we have a different domain.
I'm now trying RewriteCond and RwriteRule in the vhost... maybe that will bring me something.

As for how many domains/subdomain, that can be hundreds in a few years.

The reason for different domains/subdomains is that we link a styelsheet and thus design to specific users.
#4

[eluser]TheFuzzy0ne[/eluser]
So you're going to create a controller for each domain? Something sounds amiss. I don't know exactly what your plan is, but I'm fairly sure that creating a controller for each domain is not the way forward.
#5

[eluser]tomcode[/eluser]
Why don't You create a DNS entry pointing to Your controller/method ? Should work, no? Or do I miss something
#6

[eluser]rogierb[/eluser]
No i'm not going to create a contoller for each domain, only the thought of it.. brrrr. Lol.

The only reason I need this setup is to route to the authorisation controller with a specific set of parameters. The parameters define where they come from and what desing to use.

Once logged in it's easy since the design is paired with the user(sort of anyways).

So basically I get something like http://www.domain.com/login/8/23 or http://portal.somedomain.com/login/3482/120

@tomcode: If I use an A record like portal.somedomain.com and route it to another server to /login/23/234 wouldnt all traffic be routed to this location and not just once? So using another controller would be near to impossible? Or am I just thick?

I'm stilll at a loss, maybe I'm going to just code is, look for the servername and check if the uristring is empty and then redirect them. Buttugly and slow...
#7

[eluser]tomcode[/eluser]
You're right, DNS does not do it in Your case.

But setting up a VirtualHost by Using the ServerPath directive should do it.

The RewriteRule used
Code:
RewriteRule ^(/sub2/.*) /www/subdomain$1
should work in a .htaccess file, too, just point it to Your controller/method

I do not understand Your remark
Quote:... and not just once? ...
#8

[eluser]rogierb[/eluser]
@tomcode

Hmm.. haven't though of serverpath, good one! I'll have to try that today.

As for the 'just once' remark, I only need it to route it when no controller is selected. So only when portal.somedomain.com is called. When portal.somedomain.com/somecontroller is called, it implies the user is logged in.

So what RewriteCond do I use to to check no uri request are done?

Almost forgot the most inportant thing;-) Thanx for the help so far;-)
#9

[eluser]rogierb[/eluser]
just a few step away from a solution;-)

This is what I got so far

RewriteEngine On

RewriteCond %{SERVER_NAME} !^.*orignaldomain\.(nl|com|de)(/*).*$
RewriteCond %{SERVER_NAME} !^$
RewriteCond $1 ^$
RewriteRule ^/(.*) http://%{SERVER_NAME}/login/%{SERVER_NAME}/


This redirects but now I'm wondering whether to remove the trailing {server_name} and just use $_SERVER['server_name'].

Does anyone know what is faster? Using a parameter or $_SERVER['server_name']?




Theme © iAndrew 2016 - Forum software by © MyBB