Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.
https://shopify.github.io/liquid/
MIT License
11.13k stars 1.39k forks source link

Incorrect request object in 404 handler #1714

Open galbaras opened 1 year ago

galbaras commented 1 year ago

When using the 404 template, the request object does not contain the URL shown in the browser's address bar. Instead, it refers to /404.

Therefore, it's impossible to use request.path, request.url, etc to identify the "not found" page. In fact, that URL doesn't appear anywhwere in any section of the page, including the HEAD tag.

Please provide this information, so that it can be used in Liquid. Specifically, I would like to create a HTTP 301 redirect based on this information, so would love to know how this can be done, and if it's not possible, have it enabled.

saumil122 commented 11 months ago

Hi @galbaras

If you are looking to setup redirection rule, you can use "URL redirects" feature [where you can add redirection rule]

Note: All the broken links are managed using "URL redirects" option. Visit: "Online Stores" > "Navigation" > "View URL redirects"

URL-redirects
galbaras commented 11 months ago

Since URL redirects don't allow wildcards/regular expressions, it's impossible to cover everything I need and keep it up to date. So either regular expressions should be supported or the 404 template should allow programmatic redirection by providing the necessary information to Liquid.