• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
(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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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