Web Hosting Talk







View Full Version : CNAME & PHP


fluffels
05-09-2008, 12:35 AM
I've got a system where I need customers to do something like set a CNAME on a subdomain, e.g. site.domain.com, which forwards to output.mydomain.com. The site it refers to needs to output specific data based on the originating domain.

Can PHP's HTTP_REFERER be used reliably? I heard that this could possibly not be the case as it's browser dependent... So what should be used?

Would it be better to attempt to implement a system using wildcards and htaccess, where the client is directed to point their site.domain.com website at customer.output.mydomain.com?

Thanks for any input :)

activelobby4u
05-09-2008, 07:59 AM
My vote for htaccess and rewrite rules :agree:

01globalnet
05-09-2008, 08:29 AM
Is there a need to redirect visitors to your domain ?

Using site.domain.com the pages are served from your server, so the PHP var $_SERVER['SERVER_NAME'] will have the value "site.domain.com" and you can present data for that site.

sasha
05-09-2008, 10:17 AM
what tonyFF said.

Add site.domain.com to list of server aliases in apache configuration

ServerName output.mydomain.co
ServerAlias site.domain.com, site2.domain2.com, site3.domain3.com ...

fwwebs
05-09-2008, 11:27 AM
what tonyFF said.

Add site.domain.com to list of server aliases in apache configuration

ServerName output.mydomain.co
ServerAlias site.domain.com, site2.domain2.com, site3.domain3.com ...
And create a CName entry. This method is used quite often and it's reliability is based on DNS only, not rewriting or browsers.

karlkatzke
05-10-2008, 01:58 AM
If you need to create CNAMEs dynamically, look at PowerDNS. Free MySQL-based DNS -- works pretty darned well.

01globalnet
05-10-2008, 03:29 AM
Wildcard dns would also be fine.