After hours of searching and trying different functions, I've finally successfully removed the /author/ from all of our users profile URLs. So its just /username/

However, when new users register their profile URL's all give 404's. I can fix this by going into the permalinks screen and clicking save but we register lots of users and I cannot do this for each one.

This is the function I'm using... Any Ideas!?


    add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules');
function no_author_base_rewrite_rules($author_rewrite) {
   global $wpdb;
   $author_rewrite = array();
   $authors = $wpdb->get_results("SELECT user_nicename AS nicename from $wpdb->users");   
   foreach($authors as $author) {
       $author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
       $author_rewrite["({$author->nicename})/?$"] = 'index.php?author_name=$matches[1]';
   return $author_rewrite;

if( !is_admin() ) {
add_action('init', 'author_rewrite_so_22115103');

function author_rewrite_so_22115103() {
   global $wp_rewrite; 
   if( 'author' == $wp_rewrite->author_base ) $wp_rewrite->author_base = null;

3 Answers 3


You are just doing it wrong. Adding a per user rewrite rule will just bloat the rewrite "table" and slow down the URL parsing process. You need to come up with a generic rewrite rule which will work for all users, or write an alternative url parsing using the 'do_parse_request filter.

Your core problem is that your URL structure as it is now "collides" with the url structure of posts/categories/etc, and the best way is to just use a constant predictable prefix for your user urls maybe something like /user/{user login}/... otherwise, the only sane option in a site with many users is to do your own parsing.


author_rewrite_rules is only going to be invoked when WordPress needs to regenerate the rewrite rules. So you need to give WordPress a reason to do that. Saving on the permalinks page is one way. Another would be to hook into the user_register action, which is called right after a new user is created. Inside your handler function, call flush_rewrite_rules().

  • Thanks @dave-ross... Could you give me an example of what that function might look like?
    – js111
    Mar 17, 2015 at 0:20

Also add this near the other similar two, in order to redirect the feeds as well:

$author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]&paged=$matches[2]';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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