Solved

URL-rewriting for multilingual search engine optimization of ASP.net site with localization

Posted on 2004-04-19
3
815 Views
Last Modified: 2012-05-04
I have created a multilingual website in ASP.net with some of the localized text pulled from a database and some from resource files and it works like a charm.

The site first checks whether the visitor has cookie information about the preferred language. If not, it checks the Page.Request.UserLanguages for the preferred language and tries to match that. It then also attempts to place a cookie. If the visitor wants yet another language, he/she can select a different language through a linkbutton (JavaScript) to change the language selected and the site also updates the cookie accordingly.

A possible problem is that the url of any particular page remains the same irrespective of the language served. This seems to be a problem for search engines because they would have different content (the same content in a different language) for the same url.

Also, if we don't know anything about the preferred language and the visitor is not making any selection, we will always and only serve english. Even if the spider would be able to select a language through the linkbutton we would continue to serve english because we can't place a cookie and a spider has no "UserLanguage" parameter in its requests. (Or does it?)

Now, as a consequence, I believe that I have to handle the user's conscious language selection through a plain html link with no JavaScript for spiders to select the language because spiders don't process JavaScript.

I also assume that I have to make each page available with different url for different languages being served. Of course, I don't actually want to create separate pages for the same stuff. What is the best way do rewrite the urls? I hope there is some way to request this in the web config or global.asax file with some instruction like:

if request.path contains "/de/" replace "/de/" serve document found at "(path found after "/de/")" but leave all links in the document unchanged.

This way, I could test for the requested urls what language they ask for and set the current thread's culture accordingly. I assume this would work much smoother than with request parameters (as in "...aspx?language=de") because such request parameters won't be in the links within the served page (or can they?) and some spiders might have trouble with parameters (the "dynamic pages problem").

Now, please tell me how to do such an url rewriting so that, for example, all german pages have a url with /de/ after the domain name (and english pages with an /en/) but I don't actually have to create and manage all those subdirectories.

Thank you!
0
Comment
Question by:ddetering
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
ihenry earned 385 total points
ID: 10869302
These few links contains information about url rewriting and http pipeline handling in ASP.NET,

URL Rewriting in ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/URLRewriting.asp

Rewrite.NET -- A URL Rewriting Engine for .NET
http://www.15seconds.com/issue/030522.htm

HTTP Handlers and HTTP Modules in ASP.NET
http://www.15seconds.com/issue/020417.htm

MSDN Magazine - Intercept, Monitor, and Modify Web Requests with HTTP Filters in ISAPI and ASP.NET
http://msdn.microsoft.com/msdnmag/issues/02/08/HTTPFilters/default.aspx

Securely Implement Request Processing, Filtering, and Content Redirection with HTTP Pipelines in ASP.NET
http://msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx
0
 
LVL 1

Author Comment

by:ddetering
ID: 10870347
Funny - I didn't receive notification about this answer... Just wanted to post my new approach which I hope will work and solve my problems in a better way than rewriting the url. Nevertheless, ihenry, I'll check your answer and award the points to you if you deserve them ;)

So, as a matter of fact, I am directing multiple international domains to the site anyway. The simple answer is that I can leave the language selection javascript-based _in order_ to prevent search robots from using it. For each Application_BeginRequest (or will it be sufficient for each Session_Start) event I first check whether there is a cookie with language preferences (robots don't have a cookie). If not, I see whether there is a preferred UserLanguage that I can match (robots don't have that either). If not, I check whether the client requests an international domain:

ElseIf CurrentPage.Request.ServerVariables("server_name").ToString.IndexOf("domain.de") > -1 Then
Thread.CurrentThread.CurrentCulture = New CultureInfo("de-DE")

Else (and finally,) I serve the default english content.

As a result, I can submit the international domains and be confident that the robots will index my site only once for each language, and each language has a different url for the same page in the search engine results and the urls in the search engine results also match the expectation of most search engine users.

Possible problems will only arise once I add languages that don't match as nicely an international domain, e.g. Spanish for hispanics in the US or french for francophones in Canada. I guess I will then finally have to apply url rewriting.
0
 
LVL 1

Author Comment

by:ddetering
ID: 10878594
I think this will work when I eventually will need it, but I haven't tried it yet. I particularly like the first article. However, I had thought that this url rewriting would work with just a few lines of code in the global.asax, but I guess not...
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question