CodeIgniter Forums
How to use routing to add .html suffix? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: How to use routing to add .html suffix? (/showthread.php?tid=74771)



How to use routing to add .html suffix? - tuandungb - 11-04-2019

Hi everybody.
I tried to use routing to add .html suffix .In router.php :

Code:
$routes->get('abc.html', 'Homepage::show_categories_page/abc');

I hope when I go to URL : mydomain.com/abc.html ,it would swich to above routes.But it redirect to / (index.php)

When I tried to remove .html suffix.It works perfectly 
Code:
$routes->get('abc', 'Homepage::show_categories_page/abc');

I noticed at CI 3,it can be add suffix though application/config/config.php :
Code:
$config['url_suffix'] = '.html';


But I found nothing similar as that file in CI 4.My question is how to use routing to add .html suffix?

Thank you all for your help.


RE: How to use routing to add .html suffix? - tuandungb - 11-11-2019

Do you have any susggest?


RE: How to use routing to add .html suffix? - sheldonkaku - 05-07-2020

Did you find any solution for this?


RE: How to use routing to add .html suffix? - jreklund - 05-07-2020

Haven't tried this, but I guess it's do to the fact it's interpreted as regex. So try escaping the wildcard dot.
Code:
$routes->get('abc\.html', 'Homepage::show_categories_page/abc');