Wordpress和不同国家的永久链接(具有地理定位功能)


Wordpress and permalinks for separate Countries (with Geotargeting)

我正在用Wordpress开发一个多语言网站,有4种不同的语言(英语、意大利语、俄语和西班牙语)。我过去使用过WPML和qTranslate,但我正在尝试找出一些更特别的东西。我希望能够按国家划分永久链接的网站。

例如,如果我创建了一个带有slug"about"(在英语中,例如,slug"chi siamo"在意大利语中->在WPML中很容易完成)的页面

我希望它可以从访问

  • www.domain.com/us/about->美国,英文版页面
  • www.domain.com/uk/about->英国,英文版页面
  • www.domain.com/it/chi-siamo->ITALY,以意大利语提供的页面

我已经找到了一个地理定位功能,我正在寻找的是如何设置permalink/htaccess/分类法来实现这一点。。。

更新:忘了提一下,国家名单很大(大约100个),可以是可变的

有什么想法吗?

您可以制作一个自动创建htaccess文件的c#应用程序,下面是一个示例

void translateandmake()
    {
        List<string> countrycodes = new List<string>(); //Your country code list
        countrycodes.Add("tr");
        countrycodes.Add("en");
        YandexTranslate.YandexTranslator trnslate = new YandexTranslate.YandexTranslator(); //Made with https://www.nuget.org/packages/YandexTranslate.dll/
        string output = "";
        foreach (string countrycode in countrycodes)
        {
            output += "Redirect http://example.com/" + countrycode + @"/" + trnslate.translate("about", "apikey-here-get-from-http://api.yandex.com/key/form.xml?service=trnsl", countrycode) + " /About.html" + Environment.NewLine;
            //source http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
        }
        MessageBox.Show(output);
    }

ps。我不擅长制作htaccess文件,所以请编辑htaccess部分(重定向等)

pps。这是一个输出示例:

重定向http://example.com/tr/hakkında/About.html

重定向http://example.com/en/about/About.html