[FIXED] Throw 404 if no application route

Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 07, 2007 10:08 pm

[FIXED] Throw 404 if no application route

Post by trevornorth » Fri Jan 04, 2008 11:47 am

If I visit http://mysite.com/doesnotexist I would expect to be greeted by a 404 page.  Instead I recieve a blank page using the default template.

I'm currently running SVN revision 9852 though this has been an issue with all the RCs as far as I can remember. This primarily applies to SEF urls by way of mod_rewrite, but I believe it will also impact other configurations.

To work around this I have added a condition to the main application route function as follows:

Code: Select all

function route()
		// get the full request URI
		$uri = clone(JURI::getInstance());

		$router =& $this->getRouter();
		$result = $router->parse($uri);
		// Throw 404 if no route
		if (empty($result)) { JError::raiseError(404, JText::_("Page Not Found")); }

		JRequest::set($result, 'get', false );
This simply throws a 404 if no route is returned from the router(s).  This seems to work for me without any issues, and I wanted to open it up to the floor as it would be good to have a fix for stable.

As an aside, I also get a notice from the mod_mainmenu helper library (line 97) on the blank page when attempting to display a secondary nav menu starting at level 2 as it cannot find the active menu (and consequently retrieve the active menu tree).  This of course is moot as the page shouldn't be shown in the first place but I thought it might be worth mentioning anyway.

Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Sat Nov 12, 2005 10:55 pm
Location: Israel

Re: Throw 404 if no application route

Post by mtk » Fri Jan 04, 2008 6:15 pm

Fixed in SVN, thanks...
"In a world without walls and fences,
who needs Windows & Gates?"

http://www.smartmtk.com | http://www.lighthost.co.il/webhosting-for-joomla



Return to “Q&T 1.5.x Resolved”