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.0   Updated Sunday, March 19th, 2006 at 1:13pm

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

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 ;)

Pages: « 3 [2] 1 » Show All

  1. [...] 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! [...]

  2. [...] 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. [...]

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

  4. Hi,

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

    
      [comments/page/?([0-9]{1,})/?$] => index.php?&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

  5. 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!

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

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

  8. 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.

  9. 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 :)

  10. 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?

  11. 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!

  12. 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/

  13. 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?

  14. 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. :)

  15. 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.

Pages: « 3 [2] 1 » Show All

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.