Skip to main content

How to set up URL redirect

Overview

A common use case for edge computing on the web is simple URL redirects, without having to make any changes to your site's source code.

This tutorial explains how to easily set up a basic URL redirect using KurocoEdge.

What You'll Learn

You can set up a URL redirect in KurocoEdge by following the steps below:

Create a URL redirect rule

Select a draft deployment in your KurocoEdge admin panel and click the [+Add] button in the 'Rules List' section to create a new rule.

Image from Gyazo

To set up the URL redirect operation, you first need to set the target URL for the URL redirect. This is done by configuring the URL path pattern field of the rule. In this exercise, we will set the URL path pattern to /en/about/, which corresponds to the 'About' page on the Diverta corporate website:

Image from Gyazo

tip

Specific directory or pages can be targeted using the standard URL format of /directory/subdirectory/page.

Next, go to the "Response" tab, then click the [Add Action] button to create a new action. Expand the 'Execution'section and click the [Add Field] button.

Image from Gyazo

Configure the field as follows.

FieldSettings
Field settingsRedirect URL
HTTP Status301 Permanent Redirect or 302 Temporary Redirect
Refer to the following links to learn more about the differences between a 301 and 302.
URLEnter the URL to redirect to.

In this exercise, we want to redirect from /en/about/ to /en/contact/, so we will enter the latter into the URL field.
The settings will be as follows:

Image from Gyazo

Once you have completed the above configuration, click the [Update] button at the bottom left of the page to save the changes.

Verify that the URL Redirect is working

Finally, we will verify that the URL redirect rule that was set up is working as intended.
Click the [Preview] button at the top-right of the rule or deployment in the KurocoEdge admin panel to open up a preview of your site in a new tab in your browser.

The simplest way to verify that the redirect is working is to navigate to the page where you set the redirect rule (in our case, we will visit the 'About' page located at /en/about/. The page should redirect automatically – in our case to the 'Contact' page (located at /en/contact/)

You can also right-click on the page and enter the development console, then go to the 'Network' tab. You should see the page that the redirect rule was applied to, with a 301 (or 302) status:

Image from Gyazo

When you click on the page with 301 (or 302) status, you should be able to see the Location header within the 'Headers' tab of your browser's development console with the value of the redirect URL (/en/contact/) that you've entered in the rule.

Image from Gyazo

Summary

At this point, you have successfully verified that the URL redirect operation has been implemented using KurocoEdge. The advantage of this approach is that the redirect is handled by the proxy 'on the edge,' with no changes required to your server's source code.


Support

If you have any other questions, please contact us or check out Our Discord Community.