CodeIgniter Forums
Codeigniter 3 Url without controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Codeigniter 3 Url without controller (/showthread.php?tid=64844)



Codeigniter 3 Url without controller - stefan - 04-01-2016

Hi,

I'm struggling to get my project even started.
I'm trying to remove my controller name from the url witch was easy on Codeigniter 2.0.
But now i don't get it working. Can someone please help me out so I can update my old website again.
I hope i don't have to add every single page in the route because it wil get to full.

I must say if I load a page like this:
www.example.com/function

The page loads correctly the function of the default controller
but when i add parrameters like
www.example.com/function/id

The page won't load and tries to load the Function as Controller

Can someone please help me out i'm really stuck on this.


RE: Codeigniter 3 Url without controller - PaulD - 04-01-2016

How, on CI2, did you get that to work?


RE: Codeigniter 3 Url without controller - stefan - 04-02-2016

I just did my routes like this:
Code:
//Default pages routes
$route['(:any)'] = 'Controller_name/$1';
$route['default_controller'] = 'Controller_name';
And htacces like:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And it worked for me. But when i try the same in CI3 it won't work

So maybe I better can use CI2 for my project?
Or is there a other way?


RE: Codeigniter 3 Url without controller - InsiteFX - 04-02-2016

Try this:

PHP Code:
$route['Controller_name/(.+)'] = 'Controller_name/$1'

In CI 3+ (:any) and (:num) have changed.


RE: Codeigniter 3 Url without controller - stefan - 04-02-2016

Omg so simple but very effective.
Thank you  Smile