开发者

Same database & layout for multiple domains, but different logo on each

This is a pretty open-ended question, so I'm not looking for code examples. Just thoughts on the best way to approach this problem.

I have a php, datab开发者_运维百科ase-driven website project where the client wants to have multiple domains that all use the same database, hosting, and basic layout, but the website's logo would change based upon which domain they went to.

Example: Let's say they go to "site_alpha.com". The logo would say Site Alpha. Now they go to "site_beta.com". They would receive the exact same website (from the same database), but the logo should now say Site Beta.


You want to examine the HTTP_HOST element of the built-in $_SERVER array. This will tell you the domain name that the user is accessing the site via. So, for your specific example, you could name your logo files based on the domain name and use the following code:

<img src="/images/<?php echo $_SERVER['HTTP_HOST']; ?>-logo.jpg" alt="<?php echo $_SERVER['HTTP_HOST']; ?>" />

In your specific example, this code will result in the logo file "/images/site_alpha.com-logo.jpg" being displayed for site_alpha.com, and of course "/images/site_beta.com-logo.jpg" being displayed for visitors of site_beta.com.


I am not sure what the question is.
You are using some kind of CMS, or custom written code? It would be the same "code files" for all the domains or are you writing new files per domain?

Example - If you have some type of multihost, you can put your index.php file in each domain folder, you only have to change logo image (or css class). Or you can create one index.php with some simple code that will recognize the domain adress from which you accessing the web. It's up to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜