Remove controller name from url

#1
[eluser]Giacomo[/eluser]
Hi everybody,
since I have just one controller, I would like to remove the controller name from url.

Instead this:
domain . com / index.php / welcome / function_name

Something like this:
domain . com / index.php / function_name

Is it possible?

Bye and thanks

#2
[eluser]Kemik[/eluser]
I suppose you could using routing.

#3
[eluser]garymardell[/eluser]
nah wouldnt work, you can change the welcome to say something else using routing but it would still have to be there.
If you have 2 functions in 2 different controllers then which one would get used? CI needs to be told which controller to call and use what you want gives no indication of which one.

Unless you were to do everything in one controller and use htaccess (maybe) to remove the first url segment.

Is it really important that you remove the controller name?

#4
[eluser]Giacomo[/eluser]
[quote author="gazza" date="1191089363"]nah wouldnt work, you can change the welcome to say something else using routing but it would still have to be there.
If you have 2 functions in 2 different controllers then which one would get used? CI needs to be told which controller to call and use what you want gives no indication of which one.

Unless you were to do everything in one controller and use htaccess (maybe) to remove the first url segment.

Is it really important that you remove the controller name?[/quote]
No, it's not too much important. If it would have been possible...Smile

#5
[eluser]xwero[/eluser]
It's possible in your scenario where you only have one controller to use routing. If you have several controllers you can do it too if your function names are unique.

#6
[eluser]imzyos[/eluser]
if, you want security, you could use _remap controller function to switch between all controllers

#7
[eluser]Matthew Pennell[/eluser]
[quote author="Giacomo" date="1191081377"]Hi everybody,
since I have just one controller, I would like to remove the controller name from url.

Instead this:
domain . com / index.php / welcome / function_name

Something like this:
domain . com / index.php / function_name

Is it possible?[/quote]

Code:
$routes['([a-z\_]+)$'] = "welcome/$1";

#8
[eluser]imzyos[/eluser]
i must learn RegEx ¬¬

#9
[eluser]Giacomo[/eluser]
[quote author="Buddy Bradley" date="1191151815"]
Code:
$routes['([a-z\_]+)$'] = "welcome/$1";
[/quote]
Thanks to everybody...=)

#10
[eluser]Giacomo[/eluser]
[quote author="Buddy Bradley" date="1191151815"]
Code:
$routes['([a-z\_]+)$'] = "welcome/$1";
[/quote]
Just another question: what about if i want to match all except one string?

I tried with:
Code:
$routes['([a-z\_]+)^string$'] = "welcome/$1";
But it doesn't work.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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