Welcome Guest, Not a member yet? Register   Sign In
Classes in 'welcome' handler and URI structure
#1

[eluser]ckelly06[/eluser]
I'm having what I'm guessing is a very basic problem, but I can't figure out the solution. My default controller is 'welcome.php', so that if someone goes to http://mysite.com/ that's the controller that handles the request. I'm trying to add links to some static pages ("Privacy", "Terms", "Contact Us", etc.) and instead of creating a new controller for each of those, I wanted to just create classes off the welcome.php controller that load the views for each of those.

However, when I visited http://mysite.com/privacy/ I got a 404 error. After being confused for about 10 minutes I realized that if I visited http://mysite.com/welcome/privacy the page loads correctly, but the problem is I don't want that 'welcome' in there.

Is there some way to make it so that the default handler's name is effectively 'blank' so that I can construct classes from that handler and link to them without injecting the controller's name into the URL? The only workaround I've found so far is to use the routes.php file to manually point '/privacy/' to 'welcome/privacy/' but that seems like a very bad way to do it.

Thanks in advance!
#2

[eluser]jairoh_[/eluser]
that's the purpose of routes sir.
if you won't use routing, you will use http://mysite.com/welcome/privacy because that's how it works when calling a controller function.
base_url/controllername/controllerfunction or base_url/index.php/controllername/controllerfunction and it's not a problem. i use this one.

hope this helps.




Theme © iAndrew 2016 - Forum software by © MyBB