seo url routing problem. please help me

9 months ago

hsynucak
Member | 8
+
0
-

hi;
how my url seo friendly?

this default routing url:

<lang (tr|en)/>]<presenter>[/<action>][/<id>]

output: site.com/en/article/list/5

but id=5 name adding url

sample:

id=5 , name = samsung-note-phone

output: site.com/samsung-note-phone
or
output: site.com/en/samsung-note-phone

please help me

Last edited by hsynucak (2018-12-29 22:47)

8 months ago

dkorpar
Member | 70
+
0
-

In such cases I ussually create new class which implements Nette\Application\IRouter interface and implement functionality on my own.
See more here: https://doc.nette.org/en/2.4/routing#…

8 months ago

Milo
Nette Core | 1149
+
0
-

@hsynucak The first route win, you can define more specific routes. Like:

$router = new RouteList;

# For articles reading
$router[] = new Route('[<lang (tr|en)>/]article[/<action>[/<id>]]', [
    'presenter' => 'Article',
    'action' => 'default',
]);

# Everything else
$router[] = new Route('[<lang (tr|en)>/]<name>', [
    'presenter' => 'Product',
    'action' => 'default',
]);

8 months ago

hsynucak
Member | 8
+
0
-

Milo wrote:

@hsynucak The first route win, you can define more specific routes. Like:

$router = new RouteList;

# For articles reading
$router[] = new Route('[<lang (tr|en)>/]article[/<action>[/<id>]]', [
  'presenter' => 'Article',
  'action' => 'default',
]);

# Everything else
$router[] = new Route('[<lang (tr|en)>/]<name>', [
  'presenter' => 'Product',
  'action' => 'default',
]);

thank you for your support but only firt presenter work. but other presenters not working.

sample :

$router[] = new Route('[<lang (tr|en)>/]<name>', [
    'presenter' => 'Product',
    'action' => 'default',
 ]);

$router[] = new Route('[<lang (tr|en)>/]<name>', [
    'presenter' => 'Blog',
    'action' => 'default',
 ]);

product presenter name working but blog name opened product page :(

Last edited by hsynucak (2019-01-16 16:43)

8 months ago

hsynucak
Member | 8
+
0
-

dkorpar wrote:

In such cases I ussually create new class which implements Nette\Application\IRouter interface and implement functionality on my own.
See more here: https://doc.nette.org/en/2.4/routing#…

please share sample code. and MyRouter class how add directory and use

thank you for your support

7 months ago

mr.bremm
Member | 3
+
0
-

$router[] = new Route(‘<lang (tr<name>’, [
‘presenter’ ⇒ ‘Product’,
‘action’ ⇒ ‘default’,
 ]);

$router[] = new Route(‘<lang (tr<name>’, [
‘presenter’ ⇒ ‘Blog’,
‘action’ ⇒ ‘default’,
 ]);

\--

Did you catch the error above? Both routes are the same except for the mapping.