Routing rules for static like filenames (example.com/<filename>.html)

6 years ago

tr.
Member | 79
+
0
-

Hi there,
I'm trying to develop a CMS. Users will get dynamic website with one or more pages on own domain. The website will be generate by just one Nette Presenter. I have here three renderers one for pages themselfs, one for a css file and one for images. How can I set a routing rules up?

  • URL for website: [<subdomain.>]<domain>/<filename>.html
  • URL for images: [<subdomain.>]domain/img/<filename>
  • URL for a style: [<subdomain.>]domain/css/style.css

Renderers:

  • renderDefault($subdomain, $domain, $filename) //ie. index
  • renderImage($subdomain, $domain, $filename) //ie. my.png
  • renderStyle($subdomain, $domain)

How exactly should route rules look like?

Thank you for an advice.

Tomas

6 years ago

hrach
Member | 1801
+
0
-
$container->router[] = new Route('//[<submdomain>.]<domain>/css/style.css', 'YourPresenter:style');
$container->router[] = new Route('//[<submdomain>.]<domain>/img/<filename>', 'YourPresenter:image');
$container->router[] = new Route('//[<submdomain>.]<domain>/<filename>.html', 'YourPresenter:default');
$container->router[] = new Route('//[<submdomain>.]<domain>', 'YourPresenter:default');

Something like this… I havn't tested it. For inspiration see tests: