Jump to the post that solved this thread.
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 10 Years, 8 Months ago redirect invalid forum and invalid thread to home page or index?
#1
Solved: 10 Years, 8 Months ago
How do I redirect invalid forum and invalid thread to my home page or index page?
#2
Solved: 10 Years, 8 Months ago
Hi really need this one anyone?

How to make this work?

/ Add hooks here
$plugins->add_hook("showthread_end", "invalidthread");

// Plugin info
function invalidthread_info()
{
	return array(
		"name"			=> "invalidthread",
		"description"	=> "invalidthread",
		"website"		=> "invalidthread",
		"author"		=> "invalidthread",
		"authorsite"	=> "invalidthread",
		"version"		=> "1.0",
		"guid" 			=> "",
		"compatibility" => "16*"
	);
}


function invalidthread() {

	global $mybb, $thread, $lang;


	if ($l['error_invalidthread']) {
		error("working");
	}
}
#3
Solved: 10 Years, 8 Months ago
This sounds handy. Wouldn't it better be done through .htaccess though?
#4
Solved: 10 Years, 8 Months ago
(2014-05-10, 06:02 AM)DrXotick Wrote: This sounds handy. Wouldn't it better be done through .htaccess though?

Hi thanks very much for your reply I though about it but don't know how to do it?

My SEO Plugin handles all errors except these I mean 404.....

How can I redirect invalid thread/forum using .htaccess?
#5
Solved: 10 Years, 8 Months ago
Maybe look through this old "bug" report :

http://dev.mybb.com/issues/1622
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


#6
Solved: 10 Years, 8 Months ago
Try this in your .htaccess. I would put it above any Google SEO code, but below rewrite engine on.

ErrorDocument 404 /index.php

If that doesn't work out, or optionally... Make your custom 404.html as:
<html>
<head>
<meta http-equiv="refresh" content="3; url=http://example.com/">
<title>Page doesn't exist. Redirecting you to homepage...</title>
</head>
<body>
Page doesn't exist. Redirecting you to homepage...
<br>
</body>
</html>
Content is the # of seconds before it will redirect. Set to 0 to make it immediate.

(obviously change example.com to your domain name.)
#7
Solved: 10 Years, 8 Months ago
@DrXotick thanks very much man.

@Leefish great idea thanks a lot. I will replace all :

error($lang->error_invalidthread);
error($lang->error_invalidforum);
error($lang->error_invalidpost);

With:

if (in_array($mybb->user['usergroup'], array('3','4','6'))) {
error($lang->error_invalidthread);
}
else
{
redirect("index.php", some error goes here);
}

Just nailed it thanks Smile




P.S. Do you think I can create a plugin for this without modifying core files?
#8
Solved: 10 Years, 8 Months ago
Just curious. Why would you create a plugin when you can put a single line in .htaccess

Ah. nevermind. I see you only want to target certain usergroups. Cheers.
#9
Solved: 10 Years, 8 Months ago
(2014-05-11, 04:23 PM)DrXotick Wrote: Just curious. Why would you create a plugin when you can put a single line in .htaccess

Ah. nevermind. I see you only want to target certain usergroups. Cheers.

Hi I only want to redirect invalid forum, thread, post this is not 404!
#10
Solved: 10 Years, 8 Months ago
Didn't your mom ever teach you not to yell at strangers?
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)