Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Getting URLs Under a Page to Return 404 File Not Found

Go to End

3 Posts   1948 Views

Ben Gribaudo

Community Member, 181 Posts

31 March 2009 at 9:10am

Edited: 31/03/2009 9:10am


With a fresh install of SilverStripe, the "About Us" page is located at: http://localhost/about-us/
Going to any of the following URLs results in the "About Us" page being displayed instead of a 404 file not found error:

The reason this happens is that the rounting process knows that the page is displayed by a controller and thinks that the "/abc" parts of the URL are route parameters matching to "$Action/$ID/$OtherID" in the routing rules.

This functionality makes sense if we are writing a complex controller, but when we're just serving up normal site pages, a 404 response seems appropriate to return for the "/abc" URLs. It seems like this would be the desired default behavior for Page_Controller (i.e. made a part of core).

What do y'all think?

One way to implement this--in Page_Controller:

	function handleRequest($request) {
		$action = $request->latestParam('Action');
		// if the Action param is set but the controller doesn't have a method to handle that action, display a 404 error
		if ($action && !$this->hasMethod($action)) {
			// dispaly the 404 file not found error message
		return parent::handleRequest($request);

Btw, what is the best way to display a 404 error page from the method above?

Thank you,


Community Member, 244 Posts

31 March 2009 at 9:29am

I fixed this as part of the nestedurls branch already, which will most probably be merged back for 2.4 - see

Ben Gribaudo

Community Member, 181 Posts

31 March 2009 at 10:20am

Thanks for that tip, Andrew. I am really looking forward to when nestedurls becomes a part of core. Here, we're already building a couple of sites that use it, with plans to go live with them even though nestedurls is still in beta.