Skip to main content

Managing Traffic with Redirects

Redirects allow you to seamlessly route users from one URL to another, ensuring they always reach the correct destination. They are commonly used for:

šŸ”„ Preserving SEO rankings when URLs change.
šŸ” Enforcing secure HTTPS connections.
šŸŒ Directing traffic to localized versions of a site.

šŸ” What are the Benefits of Redirects?ā€‹

Redirects help optimize user experience and security by ensuring that visitors always land on the correct and most relevant page.

Key Benefits:

  • Ensure Seamless URL Changes: Automatically direct users to new pages when URLs change.
  • Enforce HTTPS: Redirect HTTP traffic to secure HTTPS connections.
  • Improve SEO & Preserve Link Equity: Avoid broken links that impact search engine rankings.
  • Handle Legacy URLs: Maintain compatibility with old URLs or deprecated endpoints.
  • Enhance User Experience: Automatically direct visitors to localized or mobile-friendly versions of your site.

Redirect Full Pathā€‹

The following examples showcase how to create an endpoint that redirects requests. The hostname, scheme, and port are kept the same, but the entire path of the request is changed.

  • Requests to https://example-hostname.ngrok.io/example will be redirected to https://example-hostname.ngrok.io/redirect
  • Requests to https://example-hostname.ngrok.io/example/foo will be redirected to https://example-hostname.ngrok.io/redirect

Check out the redirect traffic policy action page for more details about how it functions and the parameters it accepts.

Loadingā€¦

Redirect Path Prefixā€‹

The following examples showcase how to create an endpoint that redirects requests. The hostname, scheme, and port are kept the same, but only the prefix is changed.

  • Requests to https://example-hostname.ngrok.io/example will be redirected to https://example-hostname.ngrok.io/redirect
  • Requests to https://example-hostname.ngrok.io/example/foo will be redirected to https://example-hostname.ngrok.io/redirect/foo

Check out the redirect traffic policy action page for more details about how it functions and the parameters it accepts.

Loadingā€¦

Redirect Portā€‹

The following examples showcase how to create an endpoint that redirects requests. The hostname, scheme, and path are kept the same, but only the port is changed.

  • Requests to http://example-hostname.ngrok.io:8080 will be redirected to http://example-hostname.ngrok.io:9090

Check out the redirect traffic policy action page for more details about how it functions and the parameters it accepts.

Loadingā€¦

Redirect Hostnameā€‹

The following examples showcase how to create an endpoint that redirects requests. The scheme, port, and path are kept the same, but only the hostname is changed.

  • Requests to https://example-hostname.ngrok.io will be redirected to https://other-example-hostname.ngrok.io

Check out the redirect traffic policy action page for more details about how it functions and the parameters it accepts.

Loadingā€¦