Welcome Guest, Not a member yet? Register   Sign In
Setting url suffix
#1

Hi,

in CI3 we could use url_suffix in the config. Where is this option in CI4?
Reply
#2

CI4 does not have the option.
Reply
#3

By the way, why do you need it?
Reply
#4

(This post was last modified: 07-20-2022, 09:41 AM by groovebird.)

(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
Reply
#5

Thank you.

One solution:
https://stackoverflow.com/questions/6202...as-default

Or you could customize Router to support url suffix.
Reply
#6

(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?
Reply
#7

See Creating Core System Classes — CodeIgniter 4.2.1 documentation
https://codeigniter4.github.io/CodeIgnit...asses.html
Reply
#8

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);
Reply




Theme © iAndrew 2016 - Forum software by © MyBB