You need to 301 redirect to the last page in pagination if page does not exist WP?

You need to 301 redirect to the last page in pagination if page does not exist.
The last page of pagination: https://test.com/product-category/test/page/42/
Example of page with the addition of other characters https:/test.com/product-category/test/page/42888/
Should:
To configure the 301 redirect for such pages to the last page of pagination https://test.com/product-category/test/page/42/
prompt as such to implement, and where
April 4th 20 at 13:21
0 answer

Find more questions by tags WordPress