News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

If action does not exist, redirect where I want.

Started by Biology Forums, April 05, 2015, 11:15:14 PM

Previous topic - Next topic

Biology Forums

Hello all,

What I want is if the action does not exist, I want the server to redirect to a page that I want. What file do I edit and how.

http://website.com/index.php?action=somefakeactionthatdoesntexist > redirects to > what I want.

Arantor

Edit index.php where it sets up the action list, and near the end of that it returns 'BoardIndex' if no valid action was found, you'd use redirectexit in there.

Kindred

I believe there was a 404 mod that did just this -- it even allowed you to build a "pretty" page
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

The 404 mod just handled actual 404s, not missing actions (which are handled by SMF itself)

Actually I'd be inclined to make non-existant actions actually throw an error rather than falling back to the board index.

Kindred

Yeah... they probably should.

However....
I do swear that I dealt with a mod some time ago that DID handle even incorrect actions
(I remember testing with action=blah :) )
but I can't find it on the site now...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


Biology Forums

In 1.x:

Find in index.php:

// Fall through to the board index then...
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';


Replace with:

// Fall through to the board index then...
header('Location: /index.php?action=error');
die();


Need to create an action called error.

Hope this helps others down the road.
      
      

Advertisement: