gridonic / statamic-redirects

Manage URL redirects intuitively, discover and fix 404's automagically, improve your SEO dramatically
https://statamic.com/marketplace/addons/redirects
1 stars 1 forks source link

When collection item exists, redirect Url to external site doesn't work #9

Closed amadeann closed 3 years ago

amadeann commented 4 years ago

I tried to create a redirect from a relative URL on my site:

/blog/cleaning-products-you-should-never-mix

to:

https://cleanchaps.com/blog/cleaning-products-you-should-never-mix

cleaning-products-you-should-never-mix is a collection item (blog post) on my site. The route to bold posts is defined as blog: '/blog/{slug}' in routes.yaml. Another redirect to the same page, i.e.:

from: /cleaning-products-you-should-never-mix to: https://cleanchaps.com/blog/cleaning-products-you-should-never-mix

It also works when I change the slug of the glob post to something like: /blog/cleaning-products-you-should-never-mix-modified.

When I unpublish the post the redirect works when I am logged out from Statamic.

To summarize, it looks to me like Statamic/your plugin first checks for the existence of a given collection item, and only then for a redirect.

wanze commented 3 years ago

Hi @amadeann

The behaviour you're describing is actually how the addon works: It only performs the redirects if Statamic would display a 404 otherwise. URLs resolved to content from Statamic are never redirected.

Redirects from this module are kept separate from Statamic's redirects configured in the routes.yaml file. They are only checked and possibly executed if a 404 response is created by Statamic.

Hope that helped a bit!

Cheers