WordPress.org

Ready to get started?Download WordPress

Forums

Simple 301 Redirects
[resolved] Simple 301 Redirects: How does this plugin work? (11 posts)

  1. cjvannette
    Member
    Posted 2 years ago #

    The obvious answer is "it works well." :) But what is it actually doing?

    I ask because I'm trying to understand more about WordPress and 301 redirects, and I can't find anything in the codex. My attempts to use the traditional .htaccess file edits were a frustrating failure. I'm really glad this plugin works, but in case it breaks some day, what's the underlying process?

    http://wordpress.org/extend/plugins/simple-301-redirects/

  2. scottnelle
    Member
    Plugin Author

    Posted 2 years ago #

    Black magic. ;-)

    Actually, the way it works is like this:
    # All of the redirects are serialized and stored in a single option called 301_redirects in the wp_options table.
    # On each request, WordPress reads that option prior to running anything but the core, loads the results into an array, and checks to see if the current request is in the array.
    # If the request matches one of your entries, it writes a 301 Permanently Moved header to the visitor's browser using PHP. If there's no match, it passes the request along to be processed in whatever way WordPress thinks is best.

    It's unlikely that this plugin will ever break because it's so simple and because other than looking up the option data it doesn't really rely on WordPress functionality--the comparison work and the redirect header are handled in plain old PHP.

    If you do ever have problems with it, or just want to go with the fastest option available, here's a post from the WP support site that might be helpful in getting redirects to work in .htaccess: http://wordpress.org/support/topic/proper-301-redirect-in-htaccess

    Scott

  3. scottnelle
    Member
    Plugin Author

    Posted 2 years ago #

    For anyone who may be wondering, by the way, the first version of the plugin used http://codex.wordpress.org/Function_Reference/wp_redirect to send the redirect headers but several users reported that on their server it ignored the instructions and instead returned a 302 Redirect Header. That's why the plugin no longer uses the built in WordPress functionality for redirects.

  4. cjvannette
    Member
    Posted 2 years ago #

    Thanks, Scott! Do you know if this sort of redirect looks the same from a search-engine bot's perspective? My SEO guy is the one who started this whole URL-changing rigamarole.

  5. scottnelle
    Member
    Plugin Author

    Posted 2 years ago #

    The requesting browser (or in the case of a search engine, spider) sees the same header regardless of the method used to generate it, so these redirects will be treated by search engines the same way that .htaccess redirects are.

    There is a fraction of a second of lag time while the WordPress core initializes and the request is checked so .htaccess is still the fastest and best method to use if it's available to you.

  6. cjvannette
    Member
    Posted 2 years ago #

    Oh, goody. Still not sure why I couldn't get the .htaccess method to work, but your plugin is prettier anyway. :)

  7. dColumbus
    Member
    Posted 2 years ago #

    Scott, thanks for your work on this plugin.

    With the latest versions of WP (3.3.1), is there a possibility of incompatibility? What we're experiencing is that every now and again, our site will stop responding or lag quite a bit ... no other crazy plugins installed or external resources are being loaded.

    Quick thoughts?

  8. scottnelle
    Member
    Plugin Author

    Posted 2 years ago #

    Hey dColumbus,
    It works in my testing. What the plugin actually does is very simple (one database query and then stepping through an array of URLs) so it's unlikely to be causing serious performance issues. I'd advise temporarily shutting the plugin off to see if it resolves the performance issues. If you determine that it is definitely the plugin, check with your web host about setting up your redirects in .htaccess instead. Like I said, though, I don't think the plugin is causing the issue. If you find otherwise, please let me know. :-)

  9. dColumbus
    Member
    Posted 2 years ago #

    Scott,

    Have you ever run into the "310, Too many redirects" issue before? When trying to access my site through the HTTPS protocol, I get the 310 error. I've disabled your plugin (even though I don't think it has anything to do with it) and there's no difference...

    Any ideas?

  10. scottnelle
    Member
    Plugin Author

    Posted 2 years ago #

    The only time I've run into that was when I had WordPress incorrectly configured when set up with a WP Multisite setup. I'd suggest turning off each plugin one at a time to see if you can narrow down the issue. If it still happens, make sure that the domain settings for your WP setup match the other settings stored in the Database like Homepage URL.

  11. peeveezee
    Member
    Posted 2 years ago #

    Is this plug in compatible with WordPress SEO?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic