• We have SRM 2.1.1 on WP 6.4.3 (managed WP by DreamPress). We installed SRM and migrated redirects from htaccess as recommended by DreamHost, when they migrated from Apache to NGINX. I used WP-CLI for re-creating our redirects in SRM, and the commands explicitly specified the status code (all 301). I happened to notice today that a redirect someone recently created through WP admin had a 302 status code. While trying to understand why, I discovered that if I create a new SRM redirect in WP admin, it defaults to a 302 status code. We rarely if ever have a need for a 302 redirect. 301 Moved Permanently is the first item in the HTTP Status Code drop-down, but it’s defaulting to 302 Found. Poking around in SRM, I see where a sorted status code array is returned:

    ...
    ksort( $status_code_array, SORT_NUMERIC );
    return $status_code_array;

    But no apparent way to change/override the default selected code in the drop-down menu. I prefer to change/override the default to 301 instead of asking the admin user who would normally add or edit one-off redirects, to manually select status code 301. I’m sure they simply heeded the If you don’t know what this is, leave it as is. text next to the drop-down and went with the default. Is 302 actually the default status code for SRM or is this unexpected? Can you offer any suggestions for changing the default to 301?

    Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Darin Kotter

    (@dkotter)

    Thanks for the question! 302 is indeed the default that we set. But this can easily be changed by using the srm_default_direct_status filter.

    Adding something like this will change the default to 301:

    add_filter(
    	'srm_default_direct_status',
    	function () {
    		return 301;
    	}
    );
    Thread Starter regexaurus

    (@regexaurus)

    Thank you, Darin! That works well for us.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Incorrect default status code (302) when creating new redirect? ??’ is closed to new replies.