I'm using ACF to make a multilingual site. My custom post URLs must work both with and without /en/
as prefix. E.g. mysite.com/posttype/any-slug/
and mysite.com/en/posttype/any-slug/
must display the same post.
I've tried using this rewrite rule in functions.php (and some variations of it), but have trouble getting it to work:
add_action('init', 'add_my_rule');
function add_my_rule() {
add_rewrite_rule('^en\/posttype\/[.+]$','index.php?pagename=$matches[1]','top');
}
I've noticed there's other questions with similar titles, but the cases seem to be different from this one.
mysite.com/posttype/any-slug/
andmysite.com/en/posttype/any-slug/
display both the same content, you expose your site to duplicate content issue (SEO related), right? Unless you 301 redirect one to the other...