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.