How do I correctly get redirects working?

Hello community!

My redirects are not working. My netlify site is https://musing-ritchie-b32f22.netlify.app/

I’m migrating my wordpress site to netlify and using 11ty to generate the static content.

My wordpress site uses index.php/yyyy/mm/dd/slug and there are some sites out there that link to these URLs. I’d obviously like to keep these incoming links working, so I’ve been looking at _redirects.

As an example, sites are linking to https://blog.dunnhq.com/index.php/2018/01/11/are-your-uwp-win2d-offscreen-bitmaps-dull/.
I want them redirected to https://blog.dunnhq.com/posts/2018/01/11/are-your-uwp-win2d-offscreen-bitmaps-dull/

note - I haven’t yet done the custom domain step, so replace blog.dunnhq.com with the standard netlify domain

So, basically, I want to redirect /index.php/* to /posts/:slug, but I can’t seem to get it working.

Here’s my _redirects file:

/index.php/*        /posts/:splat

I’ve ensured that this file is published by adding this to _eleventy.js:

eleventyConfig.addPassthroughCopy("_redirects");

But nothing seems to work.

Any help would be much appreciated!

Hey Steve!

I’ve checked the latest deploy log for the site and I can see that 0 redirect rules are processed. Check out the status area above the console output here: https://app.netlify.com/sites/musing-ritchie-b32f22/deploys/5f608a66cccffd000799a1f4

You might want to give the redirects guide a quick look-see, specifically the “I’m seeing 0 rules being deployed” section! :slight_smile:

1 Like

To debug if _redirects gets into the root of your website deploy, run a local build and check the _site (or your build) directory for the _redirects to make sure it gets copied.

1 Like

Many thanks - got it working! \o/

For some strange reason, I hadn’t pushed the _redirects file to git

Thanks again!

Thank you. That was my next step if I couldn’t get it to work. I did check the output, but by clicking the ‘download’ link at the top of the preview page. It downloads a zip of the output.

1 Like