Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am planning to use the Redirection plugin to do redirects. The plugin's description states that it also enables 302 redirects, but I can't see how. There's no option as such (see screenshot below).

Redirections plugin screenshot

Am I looking in the wrong place? Does anyone know how to do 302 redirects using Redirections plugin?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Considering that Redirection plugin is broken in parts, I am currently thinking of...

#1 Using Simple URLs plugin by StudioPress.

It adds a new custom post type to your Admin menu, where you can create, edit, delete, and manage URLs. It stores click counts in the form of a custom field on that custom post type, so it scales really well.

As fate would have it, the plugin does 301 redirects only. But luckily, to get it to do what I want (302 redirects), is as easy as replacing the two instances of 301 with 302 in the plugin's plugin.php file (line 152).

* * * * *

#2 setting wp_redirect on posts using a custom field. This is the code I have in mind (untested) — based on this answer:

/* The value for 'wpse58864-302-redirects' custom field should be a URL.
 * The post can be left blank, but should be published.
 * You may have to prevent caching of these posts.
 */

add_action( 'template_redirect', 'wpse58864_redirect' );
function wpse58864_redirect(){

    if ( get_post_meta($post->ID, '302-redirect', true) ) {

        $redirect_302_to = get_post_meta($post->ID, '302-redirect', true);
        wp_redirect( $redirect_302_to );
        exit;

    }

}

* * * * *

#3 This is a completely non-WordPress way. It's very simple, basic and straightforward.

First, create a directory called go (as in http://example.com/go/) with an empty index.html file in it. When you want to create a redirect, like say http://example.com/go/wordpress/, simply drop a directory (wordpress in this case) with an index.php file with nothing but the following code, in go.

<?php
    header("Location: http://wordpress.org/");
    exit;
?>

That's all. http://example.com/go/wordpress/ should now redirect you to http://wordpress.org/

share|improve this answer
    
For the lazy, I plan to maintain a fork of Simple URLs plugin that does 302 redirects here: github.com/Aahan/WP-Plugins/tree/master/simple-urls :) –  its_me Jul 18 '12 at 19:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.