Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.1   Updated Thursday, February 19th, 2009 at 7:19pm

Internal Rewrite Viewer Plugin for WordPress

This plugin has a very specific purpose – to generate a list of the current rewrite rules that WordPress is using. Unless you are writing WordPress plugins that support permalinks, this plugin will probably not be that useful to you. But if for whatever reason you need to check the rules (for debugging.. troubleshooting..) it will do the job nicely. Only newer versions of WordPress store the rules internally of course. If you have a much older version, the data will simply be in your .htaccess file.

Download

  If you have found this page useful, please consider donating. Thanks!

Change Log

  • 02-19-09 Version 1.1 – Updated to work better with newer versions of WordPress
  • 03-19-06 Version 1.0 – Initial release

Notice

This plugin will only work if you are using custom permalinks (not the WordPress default), and have allowed WordPress to add the proper code to .htaccess

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin in your WordPress control panel.
  • Try it out by going to: http://(your wordpress install)/rewrites/
  • NOTE: If that link does not work for you, try this:
    http://(your wordpress install)/index.php/rewrites/
    The link for usage may vary depending on your permalink configuration.

Example

Take a look at my rewrite page.

How it works

This plugin works by using a rewrite rule to generate a ‘fake’ page for the rewrite viewer. This is really only a call to the index with a new variable passed. When the index page detects this variable, it generates a list of the rules instead of the index page.

Of course for this plugin to work, you must be using permalinks, but if you were not, you would not be using this plugin anyway ;)

  1. Works great… Many Thanks…

  2. thanks for sharing, I will try to use it:)

  3. It’s recenly tested, Thanks for good ideas. i thing that your idea and this link http://www.automobilesdir.com rewrite rule are not same. m i ok ?? any body can reply plz??

  4. Thanks for the good ideas and book recommendations, commenters. ,

  5. This plugin has been tested, and works, with the latest release of WordPress – 2.8

  6. Version 1.1 Released

    The plugin has been updated to work better in recent versions of WordPress. It has been tested in the latest release (2.7.1)

  7. I am using permalinks and a installed your plugin But all I am getting is a 404 page.
    http://www.xhydra.com/blog/rewrite/

  8. hello, I recently create wp blog, how can i install wp-rewrite plugin. existing url does not work. http://www.worldnetzone.com/ any body can help please?

  9. rahul: This plugin simply lists the rules WordPress is using – it will not allow you to modify existing rules.

  10. 38
    rahul

    1) can U tell me how to remove those new entries from the Rewrite Entries.
    Basically I want to revert my Rewrite Rules to default.
    2) I am not able to add any more entries. Yesterady I added 3 entries to my rewrite rules. they show up in the WP_OPTIONS table. but i dont know why this plugin is NOT CONSISTENT.

  11. Thanks man. Now I finally can figure out how to fix my 404 category pages.

  12. Michel: If you have not already, I would try backing up .htaccess, emptying it, making sure it is set for write-permissions, then clicking ‘Update Permalinks’ in the admin panel. It should force a complete rebuild of them all.

  13. Neither works for me.

    I tried:
    http://www.michelfortin.com/rewrites/

    And:
    http://www.michelfortin.com/index.php/rewrites/

    Something’s fishy going on with my rewrites, which is why I would have loved it if this plugin would work. But this may be the very reason it doesn’t!

  14. LiewCF: Even calling it directly does not seem to work: http://www.liewcf.com/blog/index.php?showrewrites=1

    It does indeed sound like this is due to a plugin – it may just be a matter of going through them all to see which one. Unless it is something that was directly added to your .htaccess file.

    There is still another option you can try. Add this code somewhere in your template’s index.php file, then refresh your page:

    <?php print_r($wp_rewrite->rewrite_rules()); ?>

    It will make the page look strange probably, but you can copy the text quickly, and then remove the code. Then you will have the rules to look at :)

  15. thanks for the reply. That’s the reason I want to use your plugin to find which rules redirect to blog page… The actual path of my WordPress is http://www.liewcf.com/blog/

  16. LiewCF: It looks like you have something in place already which is adding rewrite rules, which may be keeping this from working. For example, when I go straight to your URL, it takes me to your blog page, etc.. I would try temporarily disabling whatever is doing that. What is the actual path to your WordPress install?

  17. hi, I recently upgraded my blog to WP2.0.7 from WP1.5. I install your plugin but the url does not work. You can test it at http://www.liewcf.com/blog/rewrite/
    help please?

  18. [...] I used the Internal Rewrite Viewer plugin to figure out what was going on. This Ultimate Tag Warrior bug been a source of frustration for months. Man, it was tricky to track this one down. It’s good to finally know what the issue is — and how it can be fixed! [...]

  19. [...] In my unenlightened state, I attempt to “fix” this by hacking wp-settings.php to check for rewrites made in the .htaccess file. This is not correct. The correct way is to use the internal hooks to the rewrite engine. Obviously, I searched for a plugin to do the dirty work for me which is what Custom Rewrite Rules does. (The site seems to be down so here is a mirrored copy.) In addition to Custom Rewrite Rule, WordPress Internal Rewrite Viewer Plugin is useful in showing you all the rewrite rules. [...]

  20. Antoine: It may have to do with the way comments are handled on posts that are split up into multiple pages.

  21. Hi,

    I have always wondered what the following rule’s purpose was:

    
      [comments/page/?([0-9]{1,})/?$] =&gt; index.php?&amp;paged=$1
    

    Looking at the permalink, it seems like it would allow you to see all blog comments on a page, but in the end, it is equivalent to the website’s home.

    For example, try the following permalink:
    http://www.dagondesign.com/comments/page/1

  22. 26
    Andrey

    Extremely educational plug-in, answered A LOT of my questions.

    THANK YOU!

    An observation: it is not compatible with “Custom Rewrite Rules” plugin found here: http://www.dynamiccorestudios.com/archive/wordpress-plugin-custom-rewrite-rules/

    If “Custom Rewrite Rules” is active your plugin does not show any data. I wish I knew Wordpress well enough to help with this, since these two plugins are so complementary (like two sides of the same coin, really!)

    ALSO: running it at all times and showing the rewrite rules to the world is probably not the safest thing to do (I activate my copy only when I am curious). Integrating it into the Dashboard would be so sweet!

    Once again, MANY MANY THANKS!

  23. Admin: WP 2.0.3
    Thanks Admin. I’m looking there. Still great plugin. :-)

  24. Robert: Are you using WordPress 2.0? There are a few comments about this issue on the page for the sitemap plugin.

  25. I’ve paging problems with Your great sitemaps plugin (look for the sitemap.
    I always get the first page. The …2/ does not stay.

    - Wp 2.03
    - Chmod 777 for htaccess, …
    - normal htaccess

    The I treid Your see-rewrites-plugin. But there I always get the homepage. :-/

    Hm.

  26. Nader: With WordPress 2.0, you cannot use custom query variables unless you ‘tell’ WordPress about them. To see what I mean, take a look at the source for my sitemap generator plugin – it uses a custom query var for the page number (for when the sitemap is split into multiple pages). Check out the hooks at the bottom of the file and you will see how it can be done :)

  27. Thanks a lot for programming this great plugin. I’m currently using it to find out what my upgrade 2.0 bugs are. Somehow some of my pages do not work. Can you maybe give me a hint?

    Basically I want to redirect this url http://beta.brandinfection.com/brands/125/L/Levi’s to the brand entry coming from my plugin.

    In 1.5.2 I had hard-coded rewrite rules, now I’m trying to get the plugin to add some.

    This does not work
    $new_rules['brands/([0-9]+)/([A-Z])$’] = ‘index.php?pagename=brands&b=$1&l=$2′;

    Somehow I think that the general wp rewrite rule [(brands)(/[0-9]+)?/?$] => index.php?pagename=$1&page=$2 is in the way.

    I have it set up on http://beta.brandinfection.com and would be very glad for any help

    What do you think?

  28. Wow, that’s embarressing. It’s always the utterly simple thing that you overlook, isn’t it? I actually think I would like the permalinks better without index.php in there, but then the links to my static pages don’t work when I change it. I guess I’d better leave things alone until I learn more about permalinks and rewrites. Thanks much for taking the time to help a newbie out!

  29. Nyomi: I just looked at your site – it is because of the way you are using permalinks. Try this link :)

    http://www.nyominx.com/index.php/rewrites/

  30. Yes, I made sure that I chmod’d the htaccess file to 666 first. The reason I found your plugin was because I was searching for information about why WordPress wasn’t writing anything to the htaccess file when I turned on SEF permalinking. I didn’t worry about it because everything works fine, but I did think it was really odd and tried to figure out what was behind it. Finally I saw some discussion about WP 2 storing rewrite rules internally, so I assumed it was normal not to have anything in the htaccess file (except what I put in there myself). Now I’m confused again, what else should be in there?

  31. Nyomi: Generally the default WP 2.x .htaccess file has a few more lines in it. You mentioned that you updated the permalink structure – does the .htaccess file have write-permissions so WP can add to it? If not, I would set them and update again. :)

  32. I am also getting a 404 after installing the plugin. :(

    I am using WP 2.0.3, and have tried troubleshooting this by disabling my plugins one by one, updating my permalink structure, editing a post, redownloading and reinstalling the plugin, and trying the plugin with the WP default theme instead of K2. I also tried deleting my htaccess file, which has only the following in it which I added after I moved my blog up from a subdirectory to the root directory:

    RewriteEngine on
    RewriteRule ^blog(/)?$ / [R]

    Anyway, I’m sad that this plugin isn’t working for me. I am in the process of learning about rewrites (and still need to figure out some more things to add some redirects for static HTML pages that are now incorporated into the blog) and thought this would be a really helpful learning tool for me. Any insight you can provide would be appreciated.

  33. _ck_: Perhaps. I may add support for a password or something at some point, but it seems kind of pointless, since there should not really be anything in the redirect rules that is ’sensitive’.

  34. 14
    _ck_

    Could you consider adding a security feature so that only the administrator can see the redirect page? Like a cookie check or something, not sure…

  35. [...] I tried to find a way to use /year/month/date/slug/ structure in my permalinks and also allow posts to be accessed by the slug only. Choosing either one was easy but having them both working at the same time seemed to be a problem for my WordPress installation. Adding new rewrite rules was easy after I found Rewrite viewer plugin but still WP just didn’t show up the posts. This was important because I wanted to use the long form and also let old Textpattern permalinks work as they used to. [...]

  36. Mani: Glad you found it useful! :)

  37. Congrats, U can not imagine how I reached this page! I wanted to add some custom rewrites to debug some 1.5->2.0.2 upgrade problems, I guessed they might be a tool to help me add some custom RewriteRules to WP , your plugin was just two clicks away from me, It was a great example, Thank you very much :)

  38. Axel: Did you try disabling your other plugins? What version of WP are you using? Also, did you try clicking the ‘update permalink structure’ button in the WP options?

  39. I liked the idea of this plugin. Unfortunately when I install it all I get at /rewrites/ is a 404 error…

  40. Hi Admin,
    Thank for the tip but apeerantly the problem was caused by some strage bug, aminly a missing tag in the “single.php” template file as described here : http://wordpress.org/support/topic/35805.
    Thank you though!

  41. Sarit: What version of WordPress do you have? Newer versions of WordPress keep most of the rewrite rules internally, but there still should be some WordPress stuff in the .htaccess no matter what version you use.

    Perhaps WordPress does not have write access to your .htaccess file. Make sure you set the permissions (CHMOD) on the file to 666 (or 777 depending on your config). Then in your options, click the ‘Update Permalink Structure’ button again, and see if it will recreate the entries. :)

  42. So here’s a dummie’s question;
    I’m having problems with permalinks, they lead to blank pages. My .htaccess file contains nothing but FeedBurner code (no Wordpress code), however I did set a permalink structure in my Wordpress admin panel.
    I installed this plugin to see if I get anything else (maybe.. I don’t know a thing about htaccess) but when I try to access http://www.my-paradox.net/rewrites/ it keeps loading the index page.

    Any idea why?
    Thank you!
    Sarit

  43. Hey,

    Well, sorry for bothering you, just found out my friend added a new plug-in:

    http://fucoder.com/code/permalink-redirect/

    So you just have to tell it not to touch your plug-in and now it works fine. :)

    Take Care,

    Will

  44. Will: I am not sure what the problem could be, especially since it was working. Did you add any other plugins or anything? Or change anything else?

    I would re-download the plugin, and update your permalinks again. I would also edit one of your posts, because that forces WP to re-create those things.

  45. Hey,

    Well, shoot I must have screwed something up. Now when I vist http://www.war59312.com/rewrites/ it just goes to http://www.war59312.com/ . :(

    I see this is in my htaccess file:

    RewriteRule ^rewrites/? /index.php?showrewrites=1 [QSA,L]

    So it should be working right? It was working fine and I have no idea why its not working now.

    I also tried to “Update Permalink Structure”, but no difference. And yes the plug-in is enabled.

    Any ideas?

    Thanks,

    Will

  46. Glad you like it :)

  47. Hey,

    Thanks for this very nice plug-in. :D

    I was looking for a faster way to see what htaccess rules my wp code where creating; sure beats the heck out of having to download my htaccess file every time to check. ;)

    Take Care,

    Will

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.