Title: wp rewrite
Published: February 5, 2018
Last modified: April 15, 2026

---

# 󠀁[wp rewrite <command>](https://developer.wordpress.org/cli/commands/rewrite/)󠁿

Lists or flushes the site’s rewrite rules, updates the permalink structure.

## In this article

 * [Examples](https://developer.wordpress.org/cli/commands/rewrite/?output_format=md#examples)
 * [Subcommands](https://developer.wordpress.org/cli/commands/rewrite/?output_format=md#subcommands)

[ Back to top](https://developer.wordpress.org/cli/commands/rewrite/?output_format=md#wp--skip-link--target)

 [ ⌊GitHub⌉ ](https://github.com/wp-cli/rewrite-command)

 [ View Open Issues (0) ](https://github.com/login?return_to=%2Fissues%3Fq%3Dlabel%3Acommand%3Arewrite+sort%3Aupdated-desc+org%3Awp-cli+is%3Aopen)
[ View Closed Issues (32) ](https://github.com/login?return_to=%2Fissues%3Fq%3Dlabel%3Acommand%3Arewrite+sort%3Aupdated-desc+org%3Awp-cli+is%3Aclosed)
[Create New Issue](https://github.com/wp-cli/rewrite-command/issues/new)

See the WordPress [Rewrite API](https://developer.wordpress.org/apis/rewrite) and
[WP Rewrite](https://developer.wordpress.org/reference/classes/wp_rewrite) class
reference.

### 󠀁[Examples](https://developer.wordpress.org/cli/commands/rewrite/?output_format=md#examples)󠁿

    ```
    # Flush rewrite rules
    $ wp rewrite flush
    Success: Rewrite rules flushed.

    # Update permalink structure
    $ wp rewrite structure '/%year%/%monthnum%/%postname%'
    Success: Rewrite structure set.

    # List rewrite rules
    $ wp rewrite list --format=csv
    match,query,source
    ^wp-json/?$,index.php?rest_route=/,other
    ^wp-json/(.*)?,index.php?rest_route=/$matches[1],other
    category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$,index.php?category_name=$matches[1]&amp;feed=$matches[2],category
    category/(.+?)/(feed|rdf|rss|rss2|atom)/?$,index.php?category_name=$matches[1]&amp;feed=$matches[2],category
    category/(.+?)/embed/?$,index.php?category_name=$matches[1]&amp;embed=true,category
    ```

### 󠀁[Subcommands](https://developer.wordpress.org/cli/commands/rewrite/?output_format=md#subcommands)󠁿

| Name | Description | 
| [wp rewrite flush](https://developer.wordpress.org/cli/commands/rewrite/flush/) |

Flushes rewrite rules.

  | 
| [wp rewrite list](https://developer.wordpress.org/cli/commands/rewrite/list/) |

Gets a list of the current rewrite rules.

  | 
| [wp rewrite structure](https://developer.wordpress.org/cli/commands/rewrite/structure/) |

Updates the permalink structure.

  |

 _Command documentation is regenerated at every release. To add or update an example,
please submit a pull request against the corresponding part of the codebase._