Welcome Guest, Not a member yet? Register   Sign In
Removing the main-controller's name from url
#1

Hi,

I have made a website which has almost all the operations under the same controller named "mainsite".
So my urls look like this: www.mydomain.com/mainsite/products or www.mydomain.com/mainsite/page/3 etc.
Is it possible to completely remove the "mainsite" -part from url with routes.php? Or with some other "trick" so that I wouldn't need to start moving everything from my mainsite-controller to other controllers?
Reply
#2

(This post was last modified: 08-31-2015, 09:25 AM by JoelPiccoli.)

(08-31-2015, 07:16 AM)Liquid8 Wrote: Hi,

I have made a website which has almost all the operations under the same controller named "mainsite".
So my urls look like this: www.mydomain.com/mainsite/products or www.mydomain.com/mainsite/page/3 etc.
Is it possible to completely remove the "mainsite" -part from url with routes.php? Or with some other "trick" so that I wouldn't need to start moving everything from my mainsite-controller to other controllers?


You can use the routes like it should be. Something like this...


PHP Code:
$route['products'] = 'mainsite/products';
$route['page/(:num)'] = 'mainsite/page/3'
Reply
#3

Please bro, reply if that was what you were looking for.
The web is so cool! That you need to do cool stuff... Wink
Reply
#4

I may be wrong, as I am certainly no expert, but is not the point of the MVC structure to not have one fat controller doing everything? I would suggest it would be best to make seperate out the functionality into relevant controllers like page, product, category etc. Alternatively you could simply rename the controller to something more appropriate, like 'Shop' or similar.
Reply
#5

(09-01-2015, 04:39 AM)PaulD Wrote: I may be wrong, as I am certainly no expert, but is not the point of the MVC structure to not have one fat controller doing everything? I would suggest it would be best to make seperate out the functionality into relevant controllers like page, product, category etc. Alternatively you could simply rename the controller to something more appropriate, like 'Shop' or similar.


I agree with you my friend. But, in certain occasions, you might have few pages that you don't need to create a controller to have just one method.


I'm sure that in this case I would choose a framework for the job but, if you choose, a bunch of controllers with singles methods might only complicate the things.
The web is so cool! That you need to do cool stuff... Wink
Reply




Theme © iAndrew 2016 - Forum software by © MyBB