Welcome Guest, Not a member yet? Register   Sign In
hiding controller from url
#1

[eluser]bhbutter123[/eluser]
right now some of my urls look like http://domain.com/page/pagename, is it possible to make it look like http://domain.com/pagename where pagename is still a method in the controller page? Are there any problems or disadvantages implementing this?
#2

[eluser]nicholas.byfleet[/eluser]
yes, some clever use of .htaccess could achieve this, although I am not the guy to talk to when it comes to htaccess wizardry. sorry i couldn't be of more help.
#3

[eluser]jedd[/eluser]
[quote author="bhbutter123" date="1260774045"]right now some of my urls look like http://domain.com/page/pagename, is it possible to make it look like http://domain.com/pagename where pagename is still a method in the controller page? Are there any problems or disadvantages implementing this?[/quote]

In this instance, Page is the name of your Controller, and pagename is the method in your controller, yes?

The answer is - yes, you can do what you are wanting to do here, using routes. (Read about them in the user guide.)

The answer to your second question is a bit more complex - the 'qualified' bit attached to the previous 'yes'. It means that you need to correlate your URL's to various controller/method pairings, and that can sometimes make things more complicated than it would be if you just stuck with the controller/method/param1/param2/... style of URL.

Perhaps you just need to re-think your controller and method names - if you stick with the controller = entity or noun, and method = activity or verb - you might find that your URL's make more sense.
#4

[eluser]bhbutter123[/eluser]
so what would you suggest if I have a whole bunch of static pages I need to display and use the same controller for deciding what page to use, I do not want to use a different controller for each page of my site but don't like having extra segments when http://domain.com/pagename would look better. And yes, page is the controller and pagename is the method.
#5

[eluser]jedd[/eluser]
[quote author="bhbutter123" date="1260774972"]
so what would you suggest if I have a whole bunch of static pages I need to display and use the same controller for deciding what page to use, I do not want to use a different controller for each page of my site but don't like having extra segments when http://domain.com/pagename ...
[/quote]

The handling of static pages comes up quite regularly - do a search on the forum for titles of 'static page' for some more insight.

I'd likely have a controller that handles all my static(ish) pages - I'd call it Meta, but that's just me. Other candidates are Static, Sp (static pages), Site, Info ... etc. Controllers do not have to have long names.
#6

[eluser]frenzal[/eluser]
$route[':any'] = "page";
or
$route['(:any)'] = "page/$1";

but you'll need to provide a route for anything else that isn't allowed to be sent to the page controller, anyway routes should be the easiest solution




Theme © iAndrew 2016 - Forum software by © MyBB