Redirect Wildcard

this is my vercel.json file

{
    "redirects": [
      {
        "source": "/:path(.*).pdf",
        "destination": "https://school.cdn.codelabworks.is-cool.dev/2024/Year-11/:path.pdf",
        "permanent": true
      }
    ]
  }
  

it does not work how is suppose to work

i want to redirect only all pdf files from one to another

Hey, @shadowgaming100!

Could you try the vercel.json configuration:

{
  "redirects": [
    {
      "source": "/:path*.pdf",
      "destination": "https://school.cdn.codelabworks.is-cool.dev/2024/Year-11/:path.pdf",
      "permanent": true
    }
  ]
}

The change to the source is as follows:

  • Changed "/:path(.*).pdf" to "/:path*.pdf".
  • This new pattern will match any path ending with .pdf, which is what you want.

Let us know how you get on!

in vercel i set my Root Directory as 2024/Year-11
does not work but if remove it works

i want to use as Directory Listing

the domain is https://student-hub-three.vercel.app/

settings:
Root Directory as 2024/Year-11
Directory Listing - enabled

it works now, i disabled allow files from root folder

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.