Hide $allowed_actions url segment from a url




I have a url:

segment 1 - page
segment 2 - holder page
show - allowed action on the controller
something - url segment of a DO

I would like to hide segment 3 (show) and make it looks like this:

I tried to archive this via routes.yml but it required a major refactor of the site and it still wasn’t working properly.

Would you go down the .htaccess road and how? Or is there a better way of handling this in the framework?

Thanks in advance!

// Include any relevant code. If you have a lot of code, link to a gist instead.

I literally just figured this out out last night. Revert the changes from your routes.yml (I don’t have one), and add the following to your PageController, and then flush:

// Assuming 'show' is your allowed action
private static $url_handlers = [
    '$ID!' => 'show'

Check out URL Patterns and URL Handlers to learn more.


That was AWESOME! Thank you Isaac! Huge help! :smiley:

1 Like