Skip to content

Commit

Permalink
Merge pull request #365 from 10up/docs/364-changing-default-redirect-…
Browse files Browse the repository at this point in the history
…status

Document filter for changing default redirect status code
  • Loading branch information
dkotter authored Feb 15, 2024
2 parents 21d2d06 + ac7cab5 commit 1d7410b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,26 @@ 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

### 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`.
Expand Down
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ 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.

=== 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 ==

Expand Down

0 comments on commit 1d7410b

Please sign in to comment.