Reputation: 439
I have a multilingual wordpress site that went live and replaces the old site.
Not every language is translated yet, so I want to keep the old site alongside wordpress for the other languages.
example.de
-> new wordpress siteexample.de/zh-hans/*
-> redirect to example.de/cn/
example.de/zh-hans/
-> redirect to example.de/cn/
example.de/en/*
-> redirect to example.de/en/
example.de/en/
-> just stay on example.de/en/
My .htaccess looks like this at the moment:
Redirect 302 /zh-hans/ /cn/
RedirectMatch 302 ^/(zh-hans)/. /cn/
Redirect 302 /ja/ /jp/
RedirectMatch 302 ^/(ja)/. /jp/
RedirectMatch 302 ^/(en)/. /en/
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
en
, jp
and cn
are actual folders with index.html files in them. WordPress uses en
, ja
and zh-hans
for these languages.
I have some problems with this:
example.de/ja/
and example.de/zh-hans/
are working as intendedexample.de/ja
(without ending slash) and all other language paths like that just redirect to example.de/
example.de/en
, example.de/en/
end up in a redirect loopexample.de/ja/some-path
) is opened by wordpress with a 404-pageAt this point I have no idea how to handle this and I've tried different combinations for hours.
Is there even a way to handle this via .htaccess?
Upvotes: 2
Views: 44
Reputation: 41219
Try replacing your Redirects
with RewriteRules
:
RewriteEngine on
RewriteRule ^zh-hans/?$ /cn/ [R,L]
RewriteRule ^(zh-hans)/. /cn/ [R,L]
RewriteRule ^ja/?$ /jp/ [R,L]
RewriteRule ^(ja)/. /jp/ [R,L]
RewriteRule ^en$ /en/ [L,R]
I also made the trailing slash optional in some specific patterns . It should work now.
Upvotes: 2