1

I am trying to create a 301 redirect on my WordPress site because an author's name has recently changed. Other redirects are working, but not the ones below.

Redirect 301 /author/old%20author /author/new_auther/
Redirect 301 /author/old%20author/ /author/new_auther/

Is it anything to do with the '%' characters and is there any way I can work around this without having to do it via PHP?

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
Luke Pring
  • 992
  • 3
  • 11
  • 16

1 Answers1

3

There is no need for percent encoding of spaces, just enclose the URL in quotes. See also Redirect

The old URL-path is a case-sensitive (%-decoded) path beginning with a slash. A relative path is not allowed.

Redirect "/author/old author" /author/new_auther/

When everything works as it should, you may change the status code to 301. Never test with 301.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • I did not think that would work as the URLs actually have % character in them and not spaces. Will mark correct in 10 minutes. Thanks – Luke Pring Apr 03 '17 at 11:24
  • 1
    Good answer Olaf +1. You can also use the % sign inside double quoted uri string. – Amit Verma Apr 03 '17 at 11:30
  • 1
    _“I did not think that would work as the URLs actually have % character in them and not spaces”_ – wrong. The URLs _do_ have spaces in them. But those spaces have been URL-encoded _as_ `%20`. – CBroe Apr 03 '17 at 11:30