IT Product Help FilesGENHow To...How to create regex redirects so they are not greedy

How to create regex redirects so they are not greedy

A greedy redirect will catch urls it should not and redirect them because they have a word or words in them. To avoid that, follow these steps:

Go to the dashboard by hovering over GEN - Genetic Engineering and Biotechnology News on the top left of the site: (You will only see that black bar if you are logged in):

GEN - Genetic Engineering and Biotechnology News - Google Chrome

Then go to Tools > Redirection:

Dashboard ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Create a new redirect by clicking the Add New button to reveal the fields shown below:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

In the Source Url field:

the url should be in the following format:

^/url-string/?$

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

KEY

^ means the domain

/url-string/ means the thing you want to redirect

? means it could be followed by a slash

$ means end of string.

The $ is critically important. It prevents the redirect from affecting other urls that have that string or word in it in the case of short redirects and will prevent the issue we had yesterday from happening.

Redirect Set Up Continued

Click the URL Options/ Regex drop down arrow:  

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Click the checkbox next to regex:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Click the Regex box:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Click ignore case:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Do not click to ignore slash. Leave that checkbox empty because that has been handled already by the way you constructed the source url. See the key above for details:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Fill in the target field with the url you want to redirect to:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome

Click the Add Redirect button to create the redirect:

Redirection ‹ GEN - Genetic Engineering and Biotechnology News — WordPress - Google Chrome