• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove method and ID from URL

#1
Hi, i have this url:
Code:
https://mydomain.com/article/39/being-part-of-the-riders-growth-is-worth-every-sacrifice

and i would like have:
Code:
https://mydomain.com/being-part-of-the-riders-growth-is-worth-every-sacrifice

I have tried with routes but i can't. Someone can help me please?


This is the route for article page:
Code:
$routes->add('article/(:num)/(:any)', 'Frontend/Main::article/(:any)');

With this i remove the controller from URL:
Code:
$routes->add('(:any)', 'Frontend/Main::$1');

Thanks.
Reply

#2
As you no longer have an identifier in your url, you will need to handle all logic in Frontend/Main. That function (main) will need to check if there are an article under that name or not.
Reply

#3
I think it is posible to write the route as
PHP Code:
$routes->add('/(:any)''Frontend\Main::$1'); 
And dont forget to edit your main function too.
Reply

#4
(07-10-2020, 02:54 AM)jreklund Wrote: As you no longer have an identifier in your url, you will need to handle all logic in Frontend/Main. That function (main) will need to check if there are an article under that name or not.

Sorry for my latest answer.

I have update my project. This is my URL:
Code:
https://domain.com/article/this-is-my-slug

I would like have:
Code:
https://domain.com/this-is-my-slug

How can i do? Thanks.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.