1

I got entries in the folder /cms/web/videos/ and the url display this: http://domainname.com/cms/web/videos/barco-auro.

I want it to be this: http://domainname.com/videos/barco-auro.

How do I create clean URLs? I don't find anything on this, or nothing that helps my problem.

2

In Craft 3 under your section config change the URL config

https://docs.craftcms.com/v3/sections-and-entries.html#sections

SEE: Entry URI Formats

You can select what template it should render and what URL config you want

Failing this you can use something more advanced:

https://docs.craftcms.com/v3/routing.html#advanced-routing-with-url-rules

  • Thanks, I've done both but it doesn't seem to work. Is there something wrong with this code? code: return [ // Route videos/{slug} to a template 'videos/<entrySlug:{slug}>' => ['template' => 'templates/videos/_entry'], ]; – Sebastiaan Schillebeeckx Aug 12 at 7:18
  • What error are you getting? Page not found or Variable "entry" does not exist. – Dean Sanderson Aug 12 at 7:34
  • "Not Found The requested URL /videos/elia was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request." – Sebastiaan Schillebeeckx Aug 12 at 7:46
  • Remove templates/ from your template variable, try: 'videos/<entrySlug:{slug}>' => ['template' => 'videos/_entry'] – Dean Sanderson Aug 12 at 7:56
  • That also doesn't work. Maybe I have to do something with my folder structure? – Sebastiaan Schillebeeckx Aug 12 at 19:50
2

I'd always defer to a Brad Bell answer, but if for some reason you needed to maintain the URI format and wanted to still customize a route you could use the Routes section of settings. https://docs.craftcms.com/v3/routing.html#dynamic-routes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.