Welcome Guest, Not a member yet? Register   Sign In
Problems with Auto Routing and URI Segments
#1

Hi All,

I have set the "setAutoRoute" to true and also set $autoRoutesImproved to true in "app/Config/Feature.php"

When I try to reach http://localhost/MyProjects/index.php/Home/Test ->  I get success result.

But When I remove index.php to reach http://localhost/MyProjects/Home/Test  -> I get 404 - File Not Found

*** I want to remove index.php in this Link http://localhost/MyProjects/index.php/Home/Test

please guide me Thanks all
Reply
Reply
#3

(This post was last modified: 01-07-2023, 08:09 PM by hieuhiti.)

(01-07-2023, 05:22 AM)kenjis Wrote: See
https://codeigniter4.github.io/CodeIgnit...-in-my-url
https://codeigniter4.github.io/CodeIgnit...nning.html

Thanks Kenjis, 

I make sure the configuration is correct and working (If I set $autoRoutesImproved to true in "app/Config/Feature.php");
When I set $autoRoutesImproved to false, and I remove index.php to reach http://localhost/MyProjects/Home/Test  -> I get 404 - File Not Found

Since v4.2.0, the new more secure Auto Routing has been introduced. 
My Projects is Ci Version 4.2.11

Before set $autoRoutesImproved to true, My Project works fine,

I want to use Auto Routing (Improved),  I have set the "setAutoRoute" to true and also set $autoRoutesImproved to true in "app/Config/Feature.php" but My Projects don't Working.
Reply
#4

(01-07-2023, 08:07 PM)hieuhiti Wrote: Before set $autoRoutesImproved to true, My Project works fine,

Do you mean when you set $autoRoutesImproved to false it works fine?

If so, you don't understand auto routing improved well.
Auto routing improved is completely different from legacy auto routing.
You need to follow the new rules:
See https://codeigniter4.github.io/CodeIgnit...to-routing
Reply
#5
Heart 

(01-07-2023, 09:00 PM)kenjis Wrote:
(01-07-2023, 08:07 PM)hieuhiti Wrote: Before set $autoRoutesImproved to true, My Project works fine,

Do you mean when you set $autoRoutesImproved to false it works fine?

If so, you don't understand auto routing improved well.
Auto routing improved is completely different from legacy auto routing.
You need to follow the new rules:
See https://codeigniter4.github.io/CodeIgnit...to-routing

thank Kenjis , I'll stick with the old solution for now. If I have time I will learn more about the improved auto route and apply it
Reply
#6

No problem.

The risk in legacy auto-routing is controller filters to be bypassed.
If you don't use controller filters, you have no risk.
If you use controller filters, you can check the filters with "php spark routes" command.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB