Title: Using Redirect API
Last modified: September 1, 2016

---

# Using Redirect API

 *  Resolved [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/)
 * Hello,
 * So we use the rather dated IvyCat Testimonials plugin which registers custom 
   post type of Testimonial. The default permalink structure is /blog/%postname%/
   but we want the testimonials to just be /testimonials/ whereas right now it has/
   blog/testimonials/ (which results in 404 since the plugin post type uses only/%
   postname%/.
 * On my local install modifying the rewrite field in the plugin code where the 
   post type is created from `'rewrite' => TRUE` to `'rewrite' =>array('slug' =>'
   testimonials', 'with_front' => FALSE)` does the trick perfectly.
 * However the same change on the live environment results in no change. At this
   point I cannot figure out why. Have flushed the rules by re-saving the permalink
   settings and disabled and re-enabled the plugin.
 * I also tried to add it myself in my theme functions file following info found:
   [http://code.tutsplus.com/tutorials/the-rewrite-api-the-basics–wp-25474](http://code.tutsplus.com/tutorials/the-rewrite-api-the-basics–wp-25474)
   But I don’t understand the WP rewrite process enough to really understand what
   I am doing.
 * In essence I want WP to know how to handle /testimonials/ or at the least tell
   it to evaluate /testimonials/ as /blog/testimonials/.
 * Would greatly appreciate any hints on the proper avenues to get this accomplished
   would be greatly appreciated.

Viewing 13 replies - 1 through 13 (of 13 total)

 *  [cedcommerce](https://wordpress.org/support/users/cedcommerce/)
 * (@cedcommerce)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537587)
 * Hi gunnerman1,
    Please check if the plugin provides you setting on settings->
   permalink section. If is it so you can customize it directly from here. Can you
   please provide link of your site , so I can understand the scenario more clearly.
   Thanks
 *  [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537769)
 * Hi gunnerman1,
 * That’s really odd. I believe that you’ve got to have somehting interfering the
   the URL in order to make the testimonials appear at /blog/testimonials.
 * A few questions:
    1. Are there different plugins or theme active locally versus on the server?
    2. Is the functions file in both places identical?
    3. Are you using the slug `testimonials` for a blog post?
    4. Are you using an SEO plugin that allows you to rewrite URLs?
    5. How about a redirection plugin like Redirection?
    6. Finally, what’s your `.htaccess` look like?
 * Thanks!
 *  Thread Starter [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537790)
 * Thanks for the replies.
 * No, there is no provided setting in permalink section.
 * To answer Eric’s questions:
 * 1. There are different plugins but any plugin that is activated on the server
   is also active locally. The local server has a couple more active plugins such
   as CM Tooltip Glossary, Interactive World Maps, Multipurpose Sliders, etc. Both
   are using the same theme.
 * 2. Functions file is identical in both places. Our local version has a few utility
   functions but they are not registered or used anywhere.
 * 3. Not entirely certain what you are asking but I don’t believe so. We want all
   of our blog posts to be at /blog/%postname%, all of our pages at top level, and
   our testimonials at /testimonials/%postname%. We never use testimonials in any
   of the slugs or names.
 * 4. We have the standard version of Yoast SEO installed which I don’t believe 
   offers any rewriting functionality.
 * 5. We use the Quick Redirects plugin since we recently changed our permalink 
   structure from /%postname%/ to /blog/%postname%/ we wanted to make sure we had
   the 301 set up for any straggling links in blogs we missed etc.
 * 6. .htaccess on local site is default WordPress
 *     ```
       # BEGIN WordPress
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /
       RewriteRule ^index\.php$ - [L]
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
       </IfModule>
       ```
   
 * The server side has some Cache Control entries but the problem persists even 
   when they are removed.
 * Thanks
 *  [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537793)
 * > 5. We use the Quick Redirects plugin since we recently changed our permalink
   > structure from /%postname%/ to /blog/%postname%/ we wanted to make sure we 
   > had the 301 set up for any straggling links in blogs we missed etc.
 * I think this may be your answer here. It sounds like you’re doing a blanket redirect,
   which is affecting testimonials too.
 * By adding the `'with_front' => FALSE` it feels like it should fix it, but that
   probably only fixes the main testimonials page, and the actual testimonial slugs
   would be broken.
 * Can you test by disabling that Quick Redirect plugin temporarily and confirming
   whether it’s contributing to the issue?
 *  Thread Starter [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537794)
 * Disabled the plugin did not fix it.
 * When I change ‘rewrite’ => TRUE to ‘rewrite’ =>array(‘slug’ => ‘testimonials’,‘
   with_front’ => FALSE) it updates all of the permalinks for the testimonials page
   from /blog/testimonials/%postname% to /testimonials/%postname%/ in all of the
   posts but WordPress still requires the old .blog/testimonial/%postname% structure.
 *  Thread Starter [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537796)
 * Bit of an update. I copied my server db and themes folder to my local version
   to ensure all of the same files existed. The local version still worked. Then
   I copied the plugins folder from the server to local so all plugins matched. 
   This broke the local links.
 * Disabling all plugins one by one until none were activated did not fix the problem
   but deleting the actual plugin files did. I found when I use my local version
   of the ivycat-ajax-testimonials plugin everything works. When I use the server
   version it does not.
 * I deleted the server version of the plugin and uploaded my local version, still
   broken on the server. Removed all cache headers in .htaccess, used incognito 
   mode, etc.
 * I am about out of hair to pull out 🙁
 *  [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537797)
 * gunnerman1,
 * Man, that’s got to be super-frustrating!
 * Are you rebuilding permalinks with each change?
    What version of PHP are you 
   running in each environment?
 *  Thread Starter [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537798)
 * I hit save settings on the permalinks settings page each time. Running PHP 5.6
   on both. Do you know where the rewrite rules are stored in the database? We are
   having a similar problem with a page directing to WooCommerce shop even after
   it has been unset. Wondering if something got jiggered in the db.
 * Also when I set permalinks to plain, all works well.
 *  [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537799)
 * Hey gunnerman1,
 * > Do you know where the rewrite rules are stored in the database?
 * Of course, WordPress rewrite rules (assuming you’re on a unix-ey system), are
   in the .htaccess file, which is at the root of your WordPress install and should
   look like what you posted earlier. If that’s default WordPress, than it’s got
   to be something in your database and Quick Redirects is the thing that makes 
   the most sense.
 * RE: Quick Redirects storage of redirects – I really don’t as I’ve no experience
   with that plugin. Might ask that developer.
 * I’d have assumed that it was stored in the `wp_options` table.
 * > We are having a similar problem with a page directing to WooCommerce shop even
   > after it has been unset.
 * Again, this makes me think you should look more closely at that Redirects plugin.
 *  Thread Starter [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537800)
 * Thats what I thought but I tried to have WordPress recreate the .htaccess file
   by deleting its contents and flushing the rules as per the instructions but it
   never recreates it; have to do it manually. Changing the permalink structure 
   also does not make any changes to the .htaccess file.
 * I will try and remove the redirect plugin and see where I get.
 * Thanks
 *  [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537801)
 * > but I tried to have WordPress recreate the .htaccess file by deleting its contents
   > and flushing the rules as per the instructions but it never recreates it; have
   > to do it manually. Changing the permalink structure also does not make any 
   > changes to the .htaccess file.
 * There’s definitely something fishy going on. Is it possible that there’s some
   server security like ModSecurity blocking requests, or getting in the way?
 * If you were to blank out the .htaccess file and Save Permalinks within the wp-
   admin, you should see all the rules recreated. If that’s not happening, either
   something on the server, or in your WP install is hiccuping.
 * If removing the plugin doesn’t help, you might check with your host to see if
   they can see anything else on their end.
 *  Thread Starter [gunnerman1](https://wordpress.org/support/users/gunnerman1/)
 * (@gunnerman1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537812)
 * I resolved the problem (in part). After a bit of digging I found the db entry
   rewrite_rules was missing in the options table. Whenever I copied this db to 
   my local install this table entry would be created by WordPress on the first 
   page load.
 * The server does not seem to create this entry no matter what I try. I manually
   added the entry into the server db from my locally created entry and now all 
   of the links/redirects work properly. I know this is a serialized entry and not
   sure what implications that may have…
 * Unfortunately I fear the underlying problem still exists since WordPress still
   will not update htaccess files etc. Though at this point I have spent far too
   much time on this issue and since it is working ‘good enough’ for now I will 
   need to let it be for a while.
 * Thanks for all of the help. Very much appreciated.
 *  [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * (@sewmyheadon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537816)
 * Glad you resolved the issue. Good luck with your .htaccess woes.
 * Cheers!

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Using Redirect API’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 13 replies
 * 3 participants
 * Last reply from: [Eric Amundson](https://wordpress.org/support/users/sewmyheadon/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/using-redirect-api/#post-7537816)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
