Title: URL rewrite using code-snippets
Last modified: September 24, 2021

---

# URL rewrite using code-snippets

 *  [tenno](https://wordpress.org/support/users/ragra600/)
 * (@ragra600)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/url-rewrite-using-code-snippets/)
 * First let me say.. this is the best plugin for wordpress. It can do so many things
   and keep them easy to manage. its a life saver.
 * I would like to ask a (maybe) very basic question.
 * I am trying to add the following code snippet to rewrite the url from mysite/
   p/abc to mysite/index.phd?p=abc. But this doesnt seem to work even after resaving
   the mysite/wp-admin/options-permalink.php again and again.. What am I missing
   here?
    Thanks.
 * add_action( ‘init’, ‘my20_rewrite’,99 );
    function my20_rewrite() { add_rewrite_rule(‘
   ^p/([^/]*)/?$’, ‘index.php?p=$matches[1]’, ‘top’ ); }

The topic ‘URL rewrite using code-snippets’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

## Tags

 * [url rewrite](https://wordpress.org/support/topic-tag/url-rewrite/)

 * 0 replies
 * 1 participant
 * Last reply from: [tenno](https://wordpress.org/support/users/ragra600/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/url-rewrite-using-code-snippets/)
 * Status: not a support question