问题描述
我有这将最终支持4种语言,2个国家(美国和加拿大,英语和西班牙语)网站
I have a site that will ultimately support 4 languages and 2 countries (US & Canada, English and Spanish)
我不知道什么是设置的目录结构的最佳方式?
I'm wondering what's the best way to set up the directory structure?
现在,我有一个根网站名为site.com:
Right now, I have a root site called site.com:
这将带你到你选择你的国家和语言的页面。
This will take you to a page where you choose your country and language.
在理想情况下,我想有目录,像这样:
Ideally, I want to have the directory like so:
site.com/ca/en/ (Canada English)
site.com/ca/fr/ (Canada French)
site.com/us/en/ (US English)
site.com/us/es/ (US Spanish)
但是,这将意味着我将会把一个CA和我们虚拟目录和语言的虚拟内部的目录。是很好的做法,或者我应该这样做:
But that will mean I will be putting a "ca" and a "us" virtual directory and language virtual directories inside that. IS that good practice, or should I do something like:
site.com/ca-en/ (Canada English)
site.com/ca-fr/ (Canada French)
site.com/us-en/ (US English)
site.com/us-es/ (US Spanish)
编辑:我做了以下内容:
有一个虚拟目录:/ CA /和/美/中的应用。他们都有一个Default.aspx的这仅仅是一个重定向。就我而言,我重定向到他们的英语网站:
There is a dummy directory: /ca/ and /us/ in the application. They both have a default.aspx which is just a redirect. In my case, I redirect them to their English language sites:
例如:
site.com/ca/ - > site.com/ca/en/
site.com/us/ - > site.com/us/en /
For example: site.com/ca/ --> site.com/ca/en/site.com/us/ --> site.com/us/en/
如果输入site.com,你推到一个语言选择页面。基本上,我使用的Global.asax常规的前pression在每次请求寻找的语言/文化的字符串。
if site.com is entered, you are pushed to a language selection page. Basically, I use a regular expression in Global.asax on every request to look for the language/culture string.
这有以下好处。国家分离。所以,你有过site.com/ca/或site.com/us/控制,并能为每个国家提供了一个简单的URL。
This has the following benefits. Country separation. So you have control over site.com/ca/ or site.com/us/ and are able to provide a simple URL for each country.
总之,虚拟目录/ EN /,/ FR /和/ ES /是各自国家物理文件夹内。
Anyway, the Virtual directories /en/, /fr/ and /es/ are inside their respective country physical folders.
所以,你有以下(虚拟迪尔斯在粗体)
So you have the following (Virtual Dirs are in bold):
site.com/ca/的连接 /(默认)
site.com/ca/fr/
site.com/us/en/(默认)
site.com/us/es /
site.com/ca/en/ (default)site.com/ca/fr/site.com/us/en/ (default)site.com/us/es/
这意味着你需要有五(相同的)应用程序,除了可以使用URL来获取当前语言和国家(和它指向正确的数据库)。
What this means is that you need to have five (identical) applications, except you can use the URL to get the current language and country (and point it to the right database).
推荐答案
那么,他们想要的网址是为每个站点不同。
Well, they want the Url to be different for each site.
从本质上讲它其实是一个网站(用于维护的原因),我们使用的是全球化确定要使用的连接字符串(不同的数据库,相同的结构各一个)
Essentially it is actually one site (for maintenance reasons) and we're using globalization to determine which connection string to use (different databases, identical structures in each one)
我们每次发布,我会发布到四个位置。相同的应用程序。
Each time we publish I'll publish to four locations. Identical app.
使用一个URL全球化听起来是个好主意,但我不认为它会正常蜘蛛,即使是这样,不提供良好的可收藏的链接。 (法语的人发送链接使用设置为英语的计算机另一位法国人)。还有其他含义,但有一个原因,网站,如苹果和微软使用不同的网址每种语言/文化。
Globalization using one URL SOUNDS like a good idea, but I don't think it will spider properly, and even if it does, doesn't offer a good bookmarkable link. (French person sends link to another french person using an computer set to English). There are other implications, but there is a reason sites like apple and microsoft use different urls for each language/culture.
在每届会议开始时,我检查URL,并设置相应的连接字符串。
On each Session start, I check the url, and set the connection strings accordingly.
最后,我只是把A / CA /和/ US /在主应用程序目录,添加一些虚拟目录,以每种语言做一个效应初探重定向到选择语言页
也许不是最好的解决办法,但它似乎是工作。
Perhaps not the best solution, but it seems to be working.
这样做的另一个好处是,如果存在着只适用于一个站点一些特殊的页面,它可以被添加到该站点仅
Another benefit of doing it this way is if there is some special page that only applies to one site, it can be added to that site only.
这篇关于对于多语言网站的虚拟目录的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!