Custom URL parameters for deploy previews?

Hello fantastic netlify support team :slight_smile:

I love your deploy preview notifications, they are (another) awesome part of your crazy-good product.

I do have a question: our bare domain URL (without a path or parameters) is not designed to be visited directly, as we generate unique links for users to view and visit our content.

My question is: Is there a way to modify the path or add parameters to the commit and/or deploy preview URLs generated by netlify ?

Thank you :slight_smile:

Hiya @danielthedifficult .

You can add anything you want to a deploy by deploying it :upside_down_face: . For automatic behavior on page visit to the root, Iā€™d suggest that you can create a redirect just and only for ā€œ/ā€ that pushes people to the URL you want them at:

Something like

/ /landing-page 301

ā€¦in your _redirects file should do the job.

If that wonā€™t suit, could you let me know more about why? Then, Iā€™ll be able to try to help find a solution that better suits your needs.

Hi @fool !

Iā€™m grateful for your response, and feeling embarrassed I didnā€™t provide enough context for you to fully answer my questionā€¦ but you may have found the right path anyway.

Hereā€™s some more info, and weā€™ll see if you change your mind.

Our bare domain should 404 ā†’ it hosts a paywalled product that should only be accessible via unique links that contain a special ā€˜session codeā€™ that authenticates the user.

I have some session codes I have for testing purposes, using test users, parameters to disable analytics, etc., and Iā€™d like Netlifyā€™s GitHub deploy preview notifications (and maybe even CLI deploy notifications?) to automatically append this session code.

But, your comment about redirects has me thinkingā€¦
Maybe I can do a redirect for the bare domain but only for a deploy-preview/branch-deploy context?

Hey @danielthedifficult

It isnā€™t possible to set context-specific redirects (see Deploy Contexts) but there are options. See [Support Guide] Conditional build/deploy behavior for context / branch on Netlify for more details, plus the linked blog by @fool Selective Password Protection.

Using CONTEXT you could copy/generate a _redirects file specific to the branch/preview in the publish directory.