Is there a way to change the permalink structure in Bolt 2?

656 Views Asked by At

My current blog is on Blogger and my articles have a structure like /YYYY/MM/slug.html. Would it be possible to change the permalink structure for specific Contenttypes?

It is also the default for Wordpress.

If not possible, what is the preferred way to deal with those redirections? Something like a route matching /(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[a-z0-9\-]+)\.html that would search the database and redirect if found.

1

There are 1 best solutions below

2
On BEST ANSWER

Generating URLs like that in bolt would be hard, but accepting them is easy. Just set up an extra route to catch them, coming in.

Create a new binding in routing.yml, like this:

catcholdentries:
  path:           /{year}/{month}/{slug}
  defaults:       { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'entry' }
  requirements:
    datecreated:    '\d{4}'
    month:          '\d{2}'

Combine that with a route to create (and catch) URL's like /2014-12-19/slug-slug, and you should have something that's close to what you need.

entrybinding:
  path:           /{datecreated}/{slug}
  defaults:       { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'entry' }
  contenttype:    entries
  requirements:
    datecreated:    '\d{4}-\d{2}-\d{2}'