From beb6610aa47423987cb1318776344104b1c95edf Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:32:30 +1100 Subject: [PATCH 1/3] Provide example for changing the default status code. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 5ea22c91..58301f02 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,22 @@ This should be a path (i.e. `/test`) or a URL (i.e. `http://example.com/wp/test` ## Filters +### Default redirect status code + +The default redirect HTTP status code can be changed using the `srm_default_direct_status` filter. + +```php +add_filter( + 'srm_default_direct_status', + /** + * Set the default redirect status to 301 (Moved Permanently). + */ + function() { + return 301; + } +); +``` + ### Redirect loops detection By default redirect loop detection is disabled. To prevent redirect loops you can filter `srm_check_for_possible_redirect_loops`. From 3abf8dcc1dd39b8a815cca84a201839a7d16844d Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:32:56 +1100 Subject: [PATCH 2/3] Warn browsers cache 301 redirects. --- README.md | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 58301f02..32e0b906 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ This should be a path (i.e. `/test`) or a URL (i.e. `http://example.com/wp/test` * Developers can use `srm_additional_status_codes` filter to add status codes if needed. * Rules set with 403 and 410 status codes are handled by applying the HTTP status code and render the default WordPress `wp_die` screen with an optional message. * Rules set with a 404 status code will apply the status code and render the 404 template. +* Browsers heavily cache 301 (permanently moved) redirects. It's recommended to test your permanent redirects using the 302 (temporarily moved) status code before changing them to 301 permanently moved. ## Filters diff --git a/readme.txt b/readme.txt index 7cf2ff10..30dcb100 100644 --- a/readme.txt +++ b/readme.txt @@ -50,6 +50,7 @@ This should be a path (i.e. `/test`) or a URL (i.e. `http://example.com/wp/test` * Developers can use `srm_additional_status_codes` filter to add status codes if needed. * Rules set with 403 and 410 status codes are handled by applying the HTTP status code and render the default WordPress `wp_die` screen with an optional message. * Rules set with a 404 status code will apply the status code and render the 404 template. +* Browsers heavily cache 301 (permanently moved) redirects. It's recommended to test your permanent redirects using the 302 (temporarily moved) status code before changing them to 301 permanently moved. == Changelog == From ac7cab514cf4990802b0c0645f41d412e69471c4 Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:33:17 +1100 Subject: [PATCH 3/3] Refer to developer docs on WordPress.org page. --- readme.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.txt b/readme.txt index 30dcb100..a09c6d22 100644 --- a/readme.txt +++ b/readme.txt @@ -52,6 +52,10 @@ This should be a path (i.e. `/test`) or a URL (i.e. `http://example.com/wp/test` * Rules set with a 404 status code will apply the status code and render the 404 template. * Browsers heavily cache 301 (permanently moved) redirects. It's recommended to test your permanent redirects using the 302 (temporarily moved) status code before changing them to 301 permanently moved. +=== Developer Documentation === + +Safe Redirect Manager includes a number of actions and filters developers can make use of. These are documented on the [Safe Redirect Manager developer documentation](http://10up.github.io/safe-redirect-manager/) micro-site. + == Changelog == = 2.1.1 - 2024-01-08 =