Setting url 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: Setting url suffix (/showthread.php?tid=82378) |
Setting url suffix - groovebird - 07-04-2022 Hi, in CI3 we could use url_suffix in the config. Where is this option in CI4? RE: Setting url suffix - kenjis - 07-04-2022 CI4 does not have the option. RE: Setting url suffix - kenjis - 07-04-2022 By the way, why do you need it? RE: Setting url suffix - groovebird - 07-20-2022 (07-04-2022, 05:41 PM)kenjis Wrote: By the way, why do you need it? My Urls have the .html suffix and now it is missing, beacause CI3 generated it. In routes definiton now i have to add .html suffix in order to work RE: Setting url suffix - kenjis - 07-20-2022 Thank you. One solution: https://stackoverflow.com/questions/62024048/codeigniter-4-how-to-route-with-php-suffix-without-using-it-as-default Or you could customize Router to support url suffix. RE: Setting url suffix - groovebird - 07-20-2022 (07-20-2022, 02:40 PM)kenjis Wrote: Or you could customize Router to support url suffix. Is there any documentation how to customize the router or can you give me a tip please? RE: Setting url suffix - kenjis - 07-20-2022 See Creating Core System Classes — CodeIgniter 4.2.1 documentation https://codeigniter4.github.io/CodeIgniter4/extending/core_classes.html RE: Setting url suffix - codegrunt - 09-13-2022 This is a kludge of course (Codeigniter 4 should support this natively in my opinion) but you can do something like this. The regular expression addition strips off any .html extension before continuing on processing the route. This allows requests to work with or without ".html" as the file extension present in the original request. ./system/Router/Router.php Line 173: // Decode URL-encoded string $uri = urldecode($uri); // kludge to work around .html extension on existing links $uri = preg_replace('/(.*)\.html(\?.*)?$/','\1\2',$uri); |