Title: add_rewrite_rule causing redirection problem
Last modified: August 21, 2016

---

# add_rewrite_rule causing redirection problem

 *  Resolved [tiptap](https://wordpress.org/support/users/tiptap/)
 * (@tiptap)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/add_rewrite_rule-causing-redirection-problem/)
 * I have a url structure for my custom taxonomy called ‘feature’ in the format;
 * `http://www.mysite.com/feature/term/child-term/`
 * What I’m trying to do is add a rewrite to the beginning to allow me to prefix
   a set of values (asia|europe|africa).
 * So that a request to;
 * `http://www.mysite.com/asia/feature/term/child-term/`
 * would translate the url back to the url at the top, then add asia to the query
   var.
 * I’ve written a rewrite that does seems to do it when i test in a regex tester,
   however its causing a redirection error in the browser
 * `add_rewrite_rule('^(europe|asia|africa)/([^/]+/)*([^/]+)/?','index.php?feature
   =$matches[3]&prefix=$matches[1]','top');`
 * ie it should go to; index.php?feature=term-name&prefix=asia
 * Perhaps I’m missing something but this has me stumped
 * Any help appreciated

Viewing 1 replies (of 1 total)

 *  Thread Starter [tiptap](https://wordpress.org/support/users/tiptap/)
 * (@tiptap)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/add_rewrite_rule-causing-redirection-problem/#post-3700110)
 * Ok I managed to solve it.
 * It seemed the place I was added the rewrite rule kept getting removed. so I moved
   it to the INIT hook and all seems fine.
 * Also it seemed to be caching a lot of the pages so I cleared that also and is
   now fine.
 * I noticed it the rewrite was getting removed by installing the ‘Monkeyman Rewrite
   Analyzer’ plugin which lists all of them.

Viewing 1 replies (of 1 total)

The topic ‘add_rewrite_rule causing redirection problem’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [tiptap](https://wordpress.org/support/users/tiptap/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/add_rewrite_rule-causing-redirection-problem/#post-3700110)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
