One page for several languages, but different domains?

J

Jon F

Hi everybody,

I have a plain good ol' HTML website that currently hosts several localized
versions of pages. That is, depending on the address/domain that users
enter into their browser, the respective page is being shown in the
underlying language, such as www.site.com -> english or www.site.fr ->
french.
In the new ASP.Net application, all pages' textual content (text + tags)
comes from a SQL Server database. While I could create one folder for each
language plus the .aspx-pages, I wonder as to whether there isn't an easier
way of dealing with this, like re-direction or assembling a QueryStrng
(i.e. <?lang=it>) that would allow me to only create ONE page and still
keep the addresses intact.

Hence, browsing to www.site.com/page.aspx and www.site.fr/page.aspx would
both lead to the *same* page.aspx (there would only be one for all
languages) and the app would use the domain to determine the right language
to be returned.

Any insights/hints would be much appreciated!
 
G

Guest

Hi everybody,

I have a plain good ol' HTML website that currently hosts several localized
versions of pages. That is, depending on the address/domain that users
enter into their browser, the respective page is being shown in the
underlying language, such aswww.site.com-> english orwww.site.fr->
french.
In the new ASP.Net application, all pages' textual content (text + tags)
comes from a SQL Server database. While I could create one folder for each
language plus the .aspx-pages, I wonder as to whether there isn't an easier
way of dealing with this, like re-direction or assembling a QueryStrng
(i.e. <?lang=it>) that would allow me to only create ONE page and still
keep the addresses intact.

Hence, browsing towww.site.com/page.aspxandwww.site.fr/page.aspxwould
both lead to the *same* page.aspx (there would only be one for all
languages) and the app would use the domain to determine the right language
to be returned.

Any insights/hints would be much appreciated!

Hi Jon

you can use Request.Url.Host to get the name of domain from the
current request. It returns "www.site.com", or "site.com" where you
would need to check the last segment (1st level domain) "com".

So, you can do something like this

string[] name = Request.Url.Host.ToLower().Split(".");
string test = name[name.length()-1];
string lang;

if (test == "com")
lang == "en";

if (test == "fr")
lang == "fr";

string sql = "select * from table where language code='"+lang + "'";
 
J

Jon F

you can use Request.Url.Host to get the name of domain from the
current request. It returns "www.site.com", or "site.com" where you
would need to check the last segment (1st level domain) "com".

So, you can do something like this
(...)

drat! I fumbled around with something almost identical in the beginning!
Back then thought this couldn't work due to the paths/mappings: the old
HTTP-app simply maps the domains to different directories on the server
where, for each language, the respective htm-files are located.
However, I didn't even think of the possibility to simply use the
webspace's provider mapping so that all domains' requests are simply being
sent to the single solution directory. That should actually work!

The only drawback with this solution is that I need some additional stuff
while being on localhost, but with a little additional work that should be
feasible.

Thanks for the pointer, Alexey!
 
J

Jon F

Hi again,
The only drawback with this solution is that I need some additional stuff
while being on localhost, but with a little additional work that should be
feasible.

done. I have added UrlMappings that will handle .../
Code:
/... paths and
translate these into a QueryString so that i.e. "www.Website.com/it/"
becomes "www.Website.com/default.aspx?lang=it". The QueryString is then
transformed into a language code. Hence, using localhost, I can sort of
simulate the domain name and "navigate" to any given language.
 
G

Guest

Hi again,
The only drawback with this solution is that I need some additional stuff
while being on localhost, but with a little additional work that should be
feasible.

done. I have added UrlMappings that will handle .../
Code:
/... paths and
translate these into a QueryString so that i.e. "www.Website.com/it/"
becomes "www.Website.com/default.aspx?lang=it". The QueryString is then
transformed into a language code. Hence, using localhost, I can sort of
simulate the domain name and "navigate" to any given language.
[/QUOTE]

Sounds great.

There are a couple of other solutions available that can help you as
well. One of them is HTTP module for URL rewriting, another one could
be done if you have access to IIS - you can make different virtual
directories, e.g. /de /en /fr pointed to the same (root) directory of
your website and use Request.Url to get a "language code" from it.
 
J

Jon F

Hi Alexey,
There are a couple of other solutions available that can help you as
well. One of them is HTTP module for URL rewriting, another one could
be done if you have access to IIS - you can make different virtual
directories, e.g. /de /en /fr pointed to the same (root) directory of
your website and use Request.Url to get a "language code" from it.

I have full access to the IIS, but the goal is to not have bunches of
aspx-pages but rather just a few for pages with sort of generic content.
My approach with UrlMappings is doing fine, but in addition I had to create
a HTTP-rewriter class, too. As it turned out, the paths became a problem -
images weren't found, hence the URL-rewriter that turns all requests, such
as <www.myweb.com/it/img/image.png> into <www.myweb.com/img/image.png>.
Works like a charm now.

Regards,
J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top