cydrobolt / polr

:aerial_tramway: A modern, powerful, and robust URL shortener
https://polrproject.org
GNU General Public License v2.0
4.98k stars 888 forks source link

Allow configuring 301 vs 302 redirect #546

Open sffc opened 4 years ago

sffc commented 4 years ago

I see in LinkController.php that it appears that redirects are hard-coded to be 301 redirects. This means that browsers should cache the redirect after they hit it for the first time. However, there are cases when a 302 redirect is preferred, such as when you plan to frequently update the destination of the short link, or when you want to collect analytics every time someone visits the short link, rather than only the first time.

Expected Behavior

The redirect type (301 or 302) should be configurable.

Current Behavior

It is hard-coded at 301.

Possible Solution

There should be a new configuration option in .env to set the redirect type.

Alternatively, this could be a per-link option. However, I think it is simpler to make the global default be configurable.