WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache and Simple Redirect Plugin (4 posts)

  1. rablegen
    Member
    Posted 4 years ago #

    I have installed W3 Total Cache and it appears to be working well.

    However, it does not seem to work well with the Simple Redirect plugin.
    When I first visit a WP page with the redirect set, the browser sends the user to the proper redirected page.

    When I hit the back button and then try to visit the page again with the redirect, I instead get the page and no redirect occurs.

    Any help would be greatly appreciated.

    Rich

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Frederick Townes
    Member
    Posted 4 years ago #

    @rablegen, I'd really have to see your code to be able to duplicate this. W3TC currently works on several blogs, some of which with hundreds of 301 redirects and redirects from Platinum SEO plugin.

  3. rablegen
    Member
    Posted 4 years ago #

    @fredericktownes, thanks for getting back to me.

    I'm not sure which code you'd like to see, but here is the code for the simple redirect plugin:

    <?php
    	/*
    	Plugin Name: Redirect
    	Plugin URI: http://www.pancak.es/plugins/redirect/
    	Description: Simple redirection using Custom Fields.
    	Author: Nick Berlette
    	Version: 0.8
    	Author URI: http://www.pancak.es/
    
    	=== How to Use ===
    	  1. On the page or post you wish to redirect from, open up the Custom Fields section
    	  2. Type in 'redirect' for the key, and then any URL for the value
    	  3. Press Add Field, save the post, and you're done!
    
    	*/
    	require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-config.php');
    	add_action('get_header', 'redirect');
    	function redirect () {
    		global $post;
    		if (is_page() || is_object($post)) {
    			if (get_post_meta($post->ID, 'redirect', true)) {
    				header('Location: ' . get_post_meta($post->ID, 'redirect', true));
    			}
    		}
    	}
    	// yeah, that's the whole plugin.
    	// great, aint it?
    ?>

    Hope this helps.

    Rich

  4. Frederick Townes
    Member
    Posted 4 years ago #

    Unfortunately, I couldn't get this code you provided working even on clean WordPress installation. here are some modifications:

    <?php
             /*
             Plugin Name: Redirect
             Plugin URI: http://www.pancak.es/plugins/redirect/
             Description: Simple redirection using Custom Fields.
             Author: Nick Berlette
             Version: 0.8
             Author URI: http://www.pancak.es/
    
             === How to Use ===
               1. On the page or post you wish to redirect from, open up the
     Custom Fields section
               2. Type in 'redirect' for the key, and then any URL for the
     value
               3. Press Add Field, save the post, and you're done!
    
             */
             require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-config.php');
             add_action('get_header', 'redirect');
             function redirect () {
                     global $post;
                     if (is_single() && is_object($post)) {
                             if (get_post_meta($post->ID, 'redirect', true)) {
                                     header('Location: ' .
     get_post_meta($post->ID, 'redirect', true));
                             }
                     }
             }
             // yeah, that's the whole plugin.
             // great, aint it?
     ?>

    Anyway as written, it will not work with page cache action because when page is cached the get_header action cannot be called.

Topic Closed

This topic has been closed to new replies.

About this Topic