开发者

.htaccess wordpress wpml use same title for seperate pages

开发者 https://www.devze.com 2023-01-26 01:55 出处:网络
I am using wordpress with 开发者_如何学GoWPML and I came across a small issue.The previous website had the urls in this format:

I am using wordpress with 开发者_如何学GoWPML 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号