.htaccess wordpress wpml 对单独的页面使用相同的标题

发布于 2024-10-03 10:57:55 字数 630 浏览 0 评论 0原文

我正在将 WordPress 与 WPML 一起使用,并且遇到了一个小问题。以前的网站的网址格式如下:

domain.com/lang/title-inglish.html

例如:

-> domain.com/hello-world.html {英语用户}

-> domain.com/fr/hello-world.html {法国用户}

问题是 WPML {WordPress 的多语言插件} 为每个翻译创建一个新页面,而 WordPress 不允许用户两次使用相同的标题,因此它添加后缀,如下所示:

-> domain.com/hello-world.html {英语用户}

-> domain.com/fr/hello-world-2.html {法国用户}

好的一点是,domain.com/fr/hello-world.html 指向了domain.com/fr/hello-world-2.html相同...

所以...

我真正需要的是 hello-world-2.html 到 hello-world.html 上的 R 301

我需要从我的 URL 中删除 '-2' {-anynumber}

提前致谢!

I am using wordpress with WPML and I came across a small issue. The previous website had the urls in this format:

domain.com/lang/title-inglish.html

eg:

-> domain.com/hello-world.html {English users}

-> domain.com/fr/hello-world.html {French users}

The problem is that WPML {Multi language plugin for wordpress} creates a new page for each translation and wordpress doesn't allow the users to use the same title twice so it adds a suffix like so:

-> domain.com/hello-world.html {English users}

-> domain.com/fr/hello-world-2.html {French users}

The good this is that somehow domain.com/fr/hello-world.html points to domain.com/fr/hello-world-2.html just the same ...

So ...

What I would really need is a R 301 on hello-world-2.html to hello-world.html

I need to remove '-2' {-anynumber} from my URLS

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月寒剑心 2024-10-10 10:57:55

您可以在 htaccess 中执行此操作:

RewriteRule ^(.*)-[0-9]+\.html?$ $1\.html [R]

但问题不在服务器中,而是在 wordpress 中......获得更好的模块或仅修补该模块会更谨慎。

You could do this in htaccess:

RewriteRule ^(.*)-[0-9]+\.html?$ $1\.html [R]

But the problem isn't in the server, it's in wordpress... It would be more prudent to get a better module or just patch that one.

风吹过旳痕迹 2024-10-10 10:57:55

WordPress 有这个限制,这是有充分理由的。

你可以破解它,但是随后,你将不得不处理许多问题。

如果您正在寻找一个不同的多语言 WordPress 插件来保持所有的 slugs 相同,您应该使用 qTranslate。但是,您应该注意 qTranslate 混合了数据库中页面的所有翻译。这就是为什么所有页面上的所有语言的所有 slugs 都相同的原因。

因此,您应该选择:

  1. WPML:有不同的翻译页面,每个页面都有不同的 slug。

  2. qTranslate:将所有翻译放在同一页面中,并且它们都共享相同的 slug。

WordPress has this restriction and it's for a very good reason.

You can hack it, but then, you'll have to deal with numerous problems.

If you're looking for a different multilingual WordPress plugin that keeps all slugs the same, you should use qTranslate. However, you should note that qTranslate mixes all translations for the page in the database. This is why all slugs are the same for all languages on all pages.

So, you should choose either:

  1. WPML: Have different pages for translations, each with a different slug.

  2. qTranslate: Put all translations in the same page and they all share the same slug.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文