Redirects using placeholder but the last placeholder has .html that I want to remove

I have this in the config:

  from = "/:cat/:year/:month/:day/:slug.html"
  to = "/:year/:slug/"
  status = 301

An example is:

It half works and redirects to /2020/:slug/ so the slug placeholder isn’t getting parsed out.

I haven’t moved DNS over yet. The site is: Rails JSON Serialized Fields - Validations |

Is what I’m trying to do possible in some way?


Hey they, @candland :wave:

Looks like this thread has been quiet for a few days since you opened this. Sorry about that!

Are you still having this issue? If so, what have you tried in the past week to debug this? Have you read our troubleshooting redirects guide? Let us know!

Hi @hillary. I looked at that troubleshooting guide… didn’t see anything related to removing the .html extension in the redirects.

The deploy says it processed the rule.

But, it’s doing the same thing. It can parse the :year value but not the :slug value.

Hey there! Can you try dropping the .html suffix in your to rule?

Hi @Scott,

I didn’t have .html in my to rule, rather in the from rule. Removed it just to test.

The rule now:

  from = "/:cat/:year/:month/:day/:slug"
  to = "/:year/:slug/"
  status = 301

Now the slug is replaced, but it has .html which is the main part I’m trying to remove with this rule.

goes here

Is there a way to get the rails-json-serialized-fields-validation part of the URL without the .html? Or a way to remove the .html in the to part of the rule?



Hey! You’re right – I meant the from condition’s .html.

Yeah, if you navigate to then that’ll strip .html :wink:

We serve the content on both URLs, for all sites. With some clever headers which we set as default, it doesn’t appear as duplicated content.

This is completely untested but you could maybe try:

      from = "/:cat/:year/:month/:day/:slug.:extension"
      to = "/:year/:slug/"
      status = 301

Tried with :extension, but no luck. Seems like maybe it’s not possible with the current system?

Drats. In which case, we won’t be able to redirect and strip the extension!

1 Like