I have a custom permalink structure which looks like this: 

```
/%category%/%postname%/

```

Category base is set to `.` and I have a few post categories but want to change a permalink structure just for one of them, named `Blog`.

So I understand that I need to rewrite URL for the posts under this category, and I'm using this:

```
add_filter('post_link', 'custom_permalink', 10, 3);

function custom_permalink ($permalink, $post, $leavename) {
    // Get the categories for the post
    $category = get_the_category($post->ID);
    if (!empty($category) && $category[0]->cat_name == "Blog") {
        $permalink = trailingslashit(home_url('/' . $post->post_name . '/'));
    }
    return $permalink;
}

```

So, the link looks ok (without the `/blog/` in URL), but the result is

> 
> error 404
> 
> 
> 

Now I guess I need to set the rewrite rules, trying to achieve it with the following:

```
add_action('generate_rewrite_rules', 'custom_rewrite_rules');

function custom_rewrite_rules($wp_rewrite) {
    // This rule will will match the post id in %postname%-%post_id% struture
    $new_rules['^/([^/]+)/?$'] = 'index.php?name=$matches[1]';
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
    return $wp_rewrite;
}

```

I suppose my rewrite rules are not correct. Could you please show me how it can be fixed?

**Update:**

I was playing with it and got to this point:

```
function custom_rewrite_rules($wp_rewrite) {
    $new_rules['([^/]*)/?$'] = 'index.php?name=$matches[1]';
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
    return $wp_rewrite;
}

```

Now the desired structure works, but i get `Error` for category pages. It means this is still wrong `([^/]*)/?$`. How can i limit it only to URL's that have something after a `/` ?