CodeIgniter Forums
Completely remove controller and function name form URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Completely remove controller and function name form URL (/thread-57090.html)



Completely remove controller and function name form URL - El Forum - 02-13-2013

[eluser]albertleao[/eluser]
Hello everyone. First time posting, I absolutely love codeigniter! Smile

Anyways I had a question.

I currently have a website with a login screen which then redirects to an authenticated user homepage.

So I have a function in my login screen controller that redirects to the authenticated user homepage if he is already logged in. What I want is for the URL to continue being the same. Is there anyway I can do this?

For example:

Login page: www.mywebsite.com/landing

Routes:
$route['default_controller'] = "landing";
$route['landing'] = '/';

Url displayed: www.mywebsite.com
_________________________

Authenticated user page: www.mywebsite.com/home

Url I want to display: www.mywebsite.com


Is this possible?



Completely remove controller and function name form URL - El Forum - 02-13-2013

[eluser]Komp[/eluser]
tried using post data?
I'm new to this too, just have some general programming knowledge...


Completely remove controller and function name form URL - El Forum - 02-13-2013

[eluser]albertleao[/eluser]
What exactly do you mean as post data?

I wouldn't feel safe allowing post data allow for entry to the authenticated homepage as I know I should never trust any data that could possibly be manipulated by the user. But you did just give me an idea. If you the user is logged in, I should just fire up another view in the landing controller rather than redirecting to a whole new controller. I guess that could work.

I don't know if there is a security issue with that, but I don't see why it shouldn't work.


Completely remove controller and function name form URL - El Forum - 02-13-2013

[eluser]Komp[/eluser]
then just give it a try Wink

I meant that you can send some data that identifies in the index page what you are willing to do... of course, this data could possibly be manipulated, thus you have to check it before using it...

maybe this is just not possible in your case, I might get you wrong, sorry in that case...


Completely remove controller and function name form URL - El Forum - 02-13-2013

[eluser]albertleao[/eluser]
I will give it a shot. Will require some coding since my index function for my authenticated user controller calls alot of functions within that controller and I would have to transfer everything to the landing controller.

I will give it a shot though Komp. Ty for your input. If anyone else has any other thoughts, I am grateful.


Completely remove controller and function name form URL - El Forum - 02-14-2013

[eluser]Komp[/eluser]
by the way... have you tried using routing...? putting like ".com/signin" where "signin" is just a route rull...? So no one can actually know what controller are you using... just saying...