Home
Support Forums

Redirects not working for some rules

Site: flamboyant-hodgkin-478e30

[[redirects]]
    from = "/features"
    to = "/"
    status = 301
[[redirects]]
    from = "/index.php?r=site/tos"
    to = "/terms-of-service/"
    status = 301
[[redirects]]
    from = "/index.php?r=site/faq"
    to = "/pricing/"
    status = 301
[[redirects]]
    from = "/index.php?r=site/pricing"
    to = "/pricing/"
    status = 301
[[redirects]]
    from = "/index.php?r=site/coverage"
    to = "/datacenters/"
    status = 301
[[redirects]]
    from = "/affiliates/idevaffiliate.php"
    to = "/affiliates/"
    status = 301
[[redirects]]
    from = "/index.php?r=site/contact"
    to = "/support/"
    status = 301

Whatever rule starts with /index.php? - it doesn’t work. Any other rule from this list works fine. Any ideas?

hi ciokan, first question, are you trying to run php on netlify?

No, those are redirects. I’m not trying to run an interpreted language on a cdn :slight_smile: It’s just a cleanup

The redirects with index.php? include query parameters IE: r=site/contact.

I cant find an exact example but just throwing an idea out there.
Examples are normally given where the query turns into a splat as below:

/store id=:id  /blog/:id  301

However, maybe something like:

/index.php r=site/coverage  /datacenters  301

might work?

View the sources I read below as they might help!

See here: https://docs.netlify.com/routing/redirects/redirect-options/#query-parameters
and here: https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file

Well there’s no store in my case and I’m not sure where index.php will fit into this scheme. Do you mean something like: /index.php r=site/coverage /datacenters 301 or / r=site/coverage /datacenters 301

1 Like

edited sorry I forgot to change that part. However, Its important to note that I am just interpreting the docs I’ve linked and havent tried this myself. You’d need the index.php part to be the key to redirect from and then use the query params to decide where to go, youll need a redirect per param I assume

yep, that was it. I didn\t think the redirect engine will split my path and make 3 sets out of it but I guess it makes sense. Thanks a lot!

Cool that worked? Gained some insight myself there so glad to help!

Please mark a solution :slight_smile: