Forum Topic: Redirecting author pages

Forum: .htaccess Forum : Redirecting • Posted by Aldo • Updated:

Hi all,

having changed my slug name from “aldolat” to “aldo”, I need to redirect all author archive URLs to the new slug, for example:


So I wrote this line in .htaccess:

RedirectMatch 301 ^/author/aldolat/?(.*)$$1

as explained in the book at page 174.

The problem is that it doesn’t work if the old URL contains a trailing slash. So, to be clear:

is redirected to:

while (note the missing trailing slash)

is correctly redirected to:

What am I doing wrong?

9 Replies to “Redirecting author pages”

Posted by Jeff Starr

Hey Aldo,

To account for the trailing slash, we can do something like this:

RedirectMatch 301 ^/author/aldolat/(.*)/?$$1

Should do it, let me know if otherwise.

Posted by Aldo •

Thanks, Jeff, for your help!

It doesn’t work, and I do not understand the reason. :(

Your modification is clear, but why doesn’t work?

Posted by Jeff Starr

I don’t know, there are many factors involved with HTTP requests, redirects, WordPress, plugins, and so forth. Have you tried using mod_rewrite, something like:

<IfModule mod_rewrite.c>
	RewriteCond %{REQUEST_URI} ^/author/aldolat/(.*)/?$ [NC]
	RewriteRule .* [R=301,L]

Maybe give that a try and fine-tune if necessary?

Posted by Aldo •

Just tried that code, but unsuccessfully.

Jeff, may I ask you to remove the 6 links in my first post and put those 6 lines into code tag?

Posted by Leon Fernandez •

Sorry to bump in, learning here as well, and just got curious, just as a test, since the (.*) is a wildcard isnt that enough (without extra question marks or slashes) for the statement?

Something like this:

RedirectMatch 301 ^/author/aldolat/(.*)$$1

Posted by Jeff Starr

@Aldo: all taken care of :)

@Leon: that may do the job, and you can omit the $:

RedirectMatch 301 ^/author/aldolat/(.*)$1

Essentially the same thing, FWIW.

Posted by Aldo •

@Leon @Jeff
We got it!

*All* the suggested directives works well, either mod_alias or mod_rewrite. The problem was me, i.e. I was trying only the URL with page 17 and never other pages (2, 5, 12, 21, and so on). In other words, all directives work well in every page, but not on page 17!! eheheh :D Very strange.

The mystery of Computer Science! :D

Posted by Jeff Starr

Awesome Aldo, glad you got it sorted! :)

Posted by Aldo •

Thank you all! ;)