Click here to Skip to main content
15,884,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I know little about code and have been spending several hours of my spare time online reading about redirects and regex. However, I'm still confused and am unsure if I'm even trying to solve my problem correctly.

When nothing is entered into the search boxes on my site, the visitor is led to this (Source) URL, which is a 404-error page:



However, when a visitor does enter words or phrases, but that yield no matching results, they are led to a blank page on my site (that as far as I know, I cannot edit), as you can see below:



I'd like to redirect all search results that yield no results, and that include all possible combinations of words, numbers, and symbols that yield no results, to a new page on my website.

Whenever I try to do this using the WordPress plugin, "Redirections," I never get the code right.

I believe that I need to use a modification of the Source URL to redirect searches like "monkeys" and "pandas" to a new page (since there is nothing about these things on my website and when you search for them, the blank page comes up).

What I have tried:

I've tried codes like:

^http:\/\/justusreinhardt.com\/\?s=\/(.*?)?&id=1585\/


I've had no results. I've been attempting different, similar codes that I've found online and have added the
$1
symbol to the end of the Target URL, but have still had no luck. For example, I've altered the section in parentheses above, so that the entire code looks like this:

^http:\/\/justusreinhardt.com\/\?s=\/(.*^)?&id=1585\/


Any help or clarification would be appreciated! Thank you so much!
Posted
Updated 27-Mar-22 13:45pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900