• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$route[':any'] issue

#11
[eluser]Randy Casburn[/eluser]
What I'm eluding to is ... are you including the index.php or have you hacked your .htaccess file correctly to allow yourself to exclude it. Just assumed earlier you had taken care of that.

Randy

#12
[eluser]EEssam[/eluser]
I'm getting "the pretty CI error surrounded by the red box" Smile

And I've index.php removed by a .htaccess file.

#13
[eluser]Randy Casburn[/eluser]
Using PHP5.2.5 and following with a completely clean build of CI it works flawlessly. You have some fundamental problem that has you tweaked and I can't figure...


.htaccess
Code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]

routes.php contains:

[':any']="welcome/test_me";

welcome
Code:
class Welcome extends Controller {
    function Welcome()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->view('welcome_message');
    }
    
    function test_me()
    {
     echo $this->uri->segment(1);
    }
}


Randy

#14
[eluser]EEssam[/eluser]
Just create a new controller or a function in your welcome controller and you'll not be able to reach it. You'll get the function or controller name printed.

I think there should be somehow a first check if function or controller exists.

#15
[eluser]Randy Casburn[/eluser]
OH!! I've misunderstood along then. Of course you cannot do that. You've told CI explicitly to ignore all other requests for methods within the 'Welcome' class since you said "intercept calls to :any" method. So what this does is "reroute" the call (in my example above) to the 'test_me' method and then echo's the string if finds at the location of URI segment 1. CI is doing exactly what you are asking it to do.

You must handle everything within your method call (test_me my example).

Does this make sense?

Randy

#16
[eluser]EEssam[/eluser]
It does. The question now how we can first check if there are controllers or methods with that name first ($this->uri->segment(1)), if so, we execute the controller or method normally otherwise test_me handle the job.

#17
[eluser]mglinski[/eluser]
Umm, dont do this. Ever.
Spend the time and manually create your pages the way everyone else does.

Trying to cheat the system just ends up cheating you out.
-Matt

#18
[eluser]Randy Casburn[/eluser]
[quote author="EEssam" date="1213685141"]It does. The question now how we can first check if there are controllers or methods with that name first ($this->uri->segment(1)), if so, we execute the controller or method normally otherwise test_me handle the job.[/quote]

This goes back to my earlier post...

Wow,

I don’t really recommend anyone doing this...ever. Just found out why this never crossed my mind. This construct sort of throws all the flexibility of CI on the floor.

Would be better to come into the default controller and branch from there the way CI is designed to operate.

Just my two cents FWIW.

Randy

#19
[eluser]Randy Casburn[/eluser]
Essentially agreeing with XtraFile

#20
[eluser]EEssam[/eluser]
You're simply saying CI is not flexible enough for the task. Sad


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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