Completely remove the author url

I’ve already removed the login, registration, and password reset stuff. i also removed all links to the author url from single, archive, and index. now i want to remove the actual route so that bots cannot discover the author username.

1 Answer
1

You can add this to .htaccess file, it will redirect all author requests looking for a number ( Author ID ) to the homepage:

#Disable Author Pages
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI}  ^/$
RewriteCond %{QUERY_STRING} ^/?author=([0-9]*) [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/? [L,R=301,NC]
</IfModule>

The PHP / WordPress way, you could use Template Redirect:

function author_page_redirect() {
    if ( is_author() ) {
        wp_redirect( home_url() );
    }
}
add_action( 'template_redirect', 'author_page_redirect' );

Leave a Comment