3

I've changed the permalink for WordPress author-pages from /author/ to the Dutch variant /auteur/. This works perfectly. However, Google is showing error 404's in the Search Console. So in order to redirect the old versions that Google knows to the new ones, I want to redirect users with a 301 redirect in the following way:

From: https://www.example.com/author/jack
To: https://www.example.com/auteur/jack

I've placed the following redirect-code in the .htaccess file, yet it doesn't seem to work:

RedirectMatch 301 ^/author/$ ^/auteur/$1

What am I missing here?

2
RedirectMatch 301 ^/author/$ ^/auteur/$1

This will only redirect /author/, but the target URL is invalid (with a ^ prefix). The target URL is an ordinary string (that accepts placeholders), not a regex.

However, since WordPress already uses mod_rewrite directives for the front controller. You should also use mod_rewrite for this redirect (as opposed to a mod_alias RedirectMatch) in order to avoid potential conflicts. (The different Apache modules: mod_alias, mod_rewrite, etc. run independently at different times during the request, regardless of the apparent order of the directives in .htaccess - this can make any potential conflicts rather confusing to debug.)

Try something like the following instead before the existing WordPress directives:

RewriteRule ^author/(.*) /auteur/$1 [R=302,L]

This will redirect /author/ to /auteur/ and /author/<anything> to /auteur/<anything>.

This is currently a 302 (temporary) redirect. Change this to a 301 (permanent) only when you are sure it's working OK. 301 redirects are cached hard by the browser so can make testing problematic.

Make sure your browser cache is clear before testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.