开发者

2 IP addresses for 1 website

I have a website that is totally in French. I plan to have an english version since few months. Everything work fine, people can switch their language and the session handle their language.

The problematic is that now I have bought a domain that is different of the french one and I guess it will require to point to the same sub-domain of the host.

I guess that I will need to make some code to check the domain name and if the user is coming to the server with the english one to switch the session to the english language otherwise to use the fren开发者_C百科ch language. Am I wrong or not?

I think I will proceed that way but many other part of the website might be completly different like Ads and Images. Is the best way to handle multilanguage website is to make many comparison of the language for these Ads and Images? or to make a duplicate of the website on an other sub-domain and link the new domain to the new folder (I really think that duplicating will be worst for the long run).

Any advice would be appreaciate.

(Both questions in this question are bolded)


If what you mean is a new domain name, point it to the same server as your first domain, and do the language checking (or whatever is required) in the PHP script:

if ($_SERVER["HTTP_HOST"] == "my_first_domain_name.fr")
 { // use french site }
elseif ($_SERVER["HTTP_HOST"] == "my_second_domain_name.fr")
 { // use english site }

you could also think about a solution that splits french content into a directory named /fr, and english content in /en.


Every site that I have built to support multiple languages detected the user's language and then stored it in their session information. How you detect their language is up to you (from their IP, defaulting to a language, etc.), but make sure you provide the user an easy way to change languages. Then, based on the session information, we would update the site copy (ie., put up a different translation), experience (ex., only show products or news stories from that locale), etc.

Having multiple copies of the site on different [sub-]domains is a viable option, though one I don't like: you will have to support and release to all those different domains.

You could also set the session variable if the user comes from your new domain. Just have both domains point to the same place.


You should aim to duplicate as little as possible.. duplicating your site will lead to maintainability problems in future.

You can point both domain names at the same server IP, and have conditional server-side code to determine which content is served to the user.

In PHP, the variable $_SERVER['SERVER_NAME'] is populated with the server name from the client's http request (e.g. 'google.com').

If people access the same php script via different domain names, you could use the value of this to decide which content to present (e.g. have an html template, with the relevant content populated from the database according to site).

In terms of advertisements, you could do the same. Something like google ads will likely take care of this for you.

More generally, we're talking about virtualhosts here. There are lots of different ways to achieve what you're after, and methods vary according to the specifics of the problem, platform, hosting constraints etc.

A lot of sites base the default language choice (and advertisements, currencies used etc) on geoip, falling back to some default.


There are a lot of ways to cut this cookie. Note that since sessions are controlled by cookies (by default at least), your users will get different sessions depending on which domain they request.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜