Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 12 Years, 9 Months, 2 Weeks ago Disable "Friendly Redirect Pages" on certain pages?
#1
Solved: 12 Years, 9 Months, 2 Weeks ago
Hi. Is it possible to disable "Friendly Redirect Pages" on certain pages? I want to disable on "View New Posts" "View Today's Posts" and "View Unread Posts (http://mods.mybb.com/view/view-unreads-posts)."

Any help will be appreciated.
#2
Solved: 12 Years, 9 Months, 2 Weeks ago
Bump.
#3
Solved: 12 Years, 9 Months, 2 Weeks ago
I think you can only fully disable them by changing the setting in your ACP > Configuration > Server and Optimization Options > Friendly Redirection Pages.
#4
Solved: 12 Years, 9 Months, 2 Weeks ago
(2012-04-12, 09:52 AM)king_og Wrote: I think you can only fully disable them by changing the setting in your ACP > Configuration > Server and Optimization Options > Friendly Redirection Pages.

He doesn't wants to fully disable it. Read the thread.
[Image: Kewlz.jpg]

^^ Click to check my rank. Big Grin
#5
Solved: 12 Years, 9 Months, 2 Weeks ago
I did, but that's the only option.

That's why I said he could only fully disable them.
#6
Solved: 12 Years, 9 Months, 2 Weeks ago
So, maybe someone could write a script, which will do the thing?
#7
Solved: 12 Years, 9 Months, 2 Weeks ago
It can be done by core editing.


I suppose.
[Image: Kewlz.jpg]

^^ Click to check my rank. Big Grin
#8
Solved: 12 Years, 9 Months, 2 Weeks ago
i think core editing is not recommended by MyBB team. specially you may face something gonna wrong when updating for next updated version files etc.
With Regards and many thanks.
------------------------------------------
#9
Solved: 12 Years, 9 Months, 2 Weeks ago
It isn't possible as standard, though you could do it by modifying the core redirect() function found in ./inc/functions.php

Here's a quick example of something that MAY work - though I haven't tested it:

/**
 * Redirect the user to a given URL with a given message
 *
 * @param string The URL to redirect the user to
 * @param string The redirection message to be shown
 */
function redirect($url, $message="", $title="")
{
	global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
	
	$plugins->run_hooks("redirect", $redirect_args);

	if($mybb->input['ajax'])
	{
		// Send our headers.
		@header("Content-type: text/html; charset={$lang->settings['charset']}");
		echo "<script type=\"text/javascript\">\n";
		if($message != "")
		{
			echo 'alert("'.addslashes($message).'");';
		}
		$url = str_replace("#", "&#", $url);
		$url = htmlspecialchars_decode($url);
		$url = str_replace(array("\n","\r",";"), "", $url);
		echo 'window.location = "'.addslashes($url).'";'."\n";
		echo "</script>\n";
		exit;
	}

	if(!$message)
	{
		$message = $lang->redirect;
	}

	$time = TIME_NOW;
	$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

	if(!$title)
	{
		$title = $mybb->settings['bbname'];
	}
	
	// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
	if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']) && (THIS_SCRIPT != 'search.php'))
		$url = htmlspecialchars($url);

		eval("\$redirectpage = \"".$templates->get("redirect")."\";");
		output_page($redirectpage);
	}
	else
	{
		$url = htmlspecialchars_decode($url);
		$url = str_replace(array("\n","\r",";"), "", $url);

		run_shutdown();
		
		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://')
		{
			header("Location: {$mybb->settings['bburl']}/{$url}");
		}
		else
		{
			header("Location: {$url}");
		}
	}

	exit;
}

Notice the part that reads

&& (THIS_SCRIPT != 'search.php')

That basically should disable the friendly redirect on any page relating to searching. As I said, it hasn't been tested, but that's the way to go about doing what you want to do. Also, i'd advise using the patches plugin by frostschutz in order to make core edits as you can then enable and disable the changes you make more easily.
#10
Solved: 12 Years, 9 Months, 2 Weeks ago
(2012-04-12, 01:04 PM)euantor Wrote: It isn't possible as standard, though you could do it by modifying the core redirect() function found in ./inc/functions.php

Here's a quick example of something that MAY work - though I haven't tested it:

/**
 * Redirect the user to a given URL with a given message
 *
 * @param string The URL to redirect the user to
 * @param string The redirection message to be shown
 */
function redirect($url, $message="", $title="")
{
	global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
	
	$plugins->run_hooks("redirect", $redirect_args);

	if($mybb->input['ajax'])
	{
		// Send our headers.
		@header("Content-type: text/html; charset={$lang->settings['charset']}");
		echo "<script type=\"text/javascript\">\n";
		if($message != "")
		{
			echo 'alert("'.addslashes($message).'");';
		}
		$url = str_replace("#", "&#", $url);
		$url = htmlspecialchars_decode($url);
		$url = str_replace(array("\n","\r",";"), "", $url);
		echo 'window.location = "'.addslashes($url).'";'."\n";
		echo "</script>\n";
		exit;
	}

	if(!$message)
	{
		$message = $lang->redirect;
	}

	$time = TIME_NOW;
	$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

	if(!$title)
	{
		$title = $mybb->settings['bbname'];
	}
	
	// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
	if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']) && (THIS_SCRIPT != 'search.php'))
		$url = htmlspecialchars($url);

		eval("\$redirectpage = \"".$templates->get("redirect")."\";");
		output_page($redirectpage);
	}
	else
	{
		$url = htmlspecialchars_decode($url);
		$url = str_replace(array("\n","\r",";"), "", $url);

		run_shutdown();
		
		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://')
		{
			header("Location: {$mybb->settings['bburl']}/{$url}");
		}
		else
		{
			header("Location: {$url}");
		}
	}

	exit;
}

Notice the part that reads

&& (THIS_SCRIPT != 'search.php')

That basically should disable the friendly redirect on any page relating to searching. As I said, it hasn't been tested, but that's the way to go about doing what you want to do. Also, i'd advise using the patches plugin by frostschutz in order to make core edits as you can then enable and disable the changes you make more easily.

I changed the code and it gives error when entering the site:
Quote:Parse error: syntax error, unexpected T_ELSE in .../inc/functions.php on line 827
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 4 Guest(s)