riasvdv / statamic-redirect

Redirect allows you to redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website.
https://statamic.com/addons/rias/redirect
19 stars 21 forks source link

Deleting entry conflicting redirects. Strange behaviour. #179

Closed stuartcusackie closed 3 months ago

stuartcusackie commented 3 months ago

Hi,

I'm trying to figure out why a redirect keeps getting deleted when I save the related entry. I can see it mentioned in the docs but this behaviour seems strange and undesirable.

id: 4d9831f8-1802-4029-a259-35567f672293
enabled: true
source: /homesweethome
destination: /events/homesweethome
type: '301'
match_type: regex

I've disabled the behaviour using the config file but I don't understand why this is the default behaviour? I'm probably missing something but thought I should open an issue in case there's a bug.

Thanks!

stuartcusackie commented 3 months ago

It was because I was using the regex match type. The reason we used regex was to maintain the query string but that was causing the redirect to be automatically deleted.

So these are the regex patterns I ended up with:

Source: ^/homesweethome(.*)$

Destination: /events/homesweethome$1

I kind of feel like query strings should be maintained by default, even with exact matches. Perhaps a checkbox to maintain query string could be added?