Welcome Guest, Not a member yet? Register   Sign In
Problems with redirect function
#1

[eluser]universal_serial_bus[/eluser]
Hi there,

I'm newbie with CI and I've some strange problems with redirect function.

I have a directory structure such as:

/controllers
. controller1.php
. controller2.php
. ...
. admin.php
/admin
. admin_controller1.php
. admin_controller2.php
. ...

So I want to access automatically to "admin_controller1.php" when I navigate in my browser to "http://mydomain.com/admin".

To do so, I'm using redirect function on index() of admin.php controller, and I'm doing just redirect('/admin/admin_controller'); but what I obtain is being redirect to "http://mydomain.com/mydomain/admin/" so, obviously, system can't find the controller.

Any idea?

I've defined my base_url as "mydomain/" and I'm including correctly the URL_Helper module.

Thanks everyone !
#2

[eluser]WanWizard[/eluser]
Afaik you can't have AND an admin controller, AND an admin folder. If both exist the controller is always loaded.
#3

[eluser]universal_serial_bus[/eluser]
@WanWizard thx for the response, you're absolutely right. But my controller name is not admin.php... I wrote that as an example. My fault.

I've a controller named "godmode.php" and a directory named "admin".
Anyway, if I try to redirect to another controller on the same folder, such as "users.php", it fails at same point.

I'm working on localhost, and the CI root directory is "/codeigniter", so my base_url has value "localhost/codeigniter/" and when I'm trying to redirect something, system automatically prepends base_url to my controller target URL... so, if I call:

"http://localhost/codeigniter/godmode/"

I execute the index() function of the controller, where I do:

redirect("/admin/test")

But I'm redirected to:

"http://localhost/codeigniter/localhost/codeigniter/admin/test"

And I don't know why it happens...
#4

[eluser]universal_serial_bus[/eluser]
Ok, I solved it just adding 'http://' to my base_url value.

Thanks for all !




Theme © iAndrew 2016 - Forum software by © MyBB