Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
514 views
in Q2A Core by
Can anyone tell me how to stop people from accessing certain pages, for example /hot

I know I can hide the option on the menu but how do I stop people from accessing that page if they manually type it in to the browser?
Q2A version: 1.6

1 Answer

+2 votes
by
selected by
 
Best answer

Override function qa_get_request_content() and redirect to home page or 404 if request is hot or whatever page you want.

Something (but not exactly) like below

if($requestparts[0] === 'hot') {
    qa_redirect_raw(qa_opt('site_url'));
}

I have tested and it is working fine. It is redirecting to the home page. You also can use qa_redirect() instead if you want to give parameters instead raw URL

See here how you can override function http://question2answer.org/overrides.php


Edit:

If you want to redirect or block multiple pages than add those in array and check with in_array() function.

I am sure there may be other ways too but I found this way at the moment. If find more than will share here.

by
Nice answer. But I want this redirection to homepage along with an error message. How to achieve that?
...