MyBB Community Forums

Full Version: .htaccess 301 redirect invalid forum, thread, post?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
It doesn't even allow me to access an active forum. Man this orange is driving me crazy.


Maybe this will nail it:

if(empty($mybb->input['fid']))
{
header("Location: {$mybb->settings['bburl']}/index.php", true, 301);
exit();
}
Please don't swear. Could you share the code for the entire plugin? That small snippet doesn't particularly help...
My formal apologies.

$plugins->add_hook("forumdisplay_start", "test");
function test_info()
{    
    return array(
                "name" => "test",
                "description" => "test",
                "website" => "test",
                "author" => "test",
                "authorsite" => "test",
                "version" => "test",
                "guid" => "",
                "compatibility" => "16*"
            );
}
function test()
{
    global $mybb;
    
if(empty($mybb->input['fid']))
{
header("Location: {$mybb->settings['bburl']}/search.php", true, 301);
exit();
}  
}          
}
Please remove the trailing }.

The following worked for me:
function test()
{
	global $mybb;

	if(empty($mybb->input['fid']))
	{
		header("Location: {$mybb->settings['bburl']}/search.php", true, 301);
		exit();
	}
	elseif(!get_forum((int)$mybb->input['fid']))
	{
		header("Location: {$mybb->settings['bburl']}/index.php", true, 301);
		exit();
	}
}
Buddy thanks very much really.

Any idea why it's not working for URLs like this one:

URL:
http://letsforum.com/Forum-Adwords-Forum

Please check the http header for this URL and you will see that location is not my homepage but forumdisplay.php
It works for me. It sends a 301 to forumdisplay.php?fid=163 then that sends a 301 to index.php.

I think you may have Google SEO configured incorrectly. Could you post your .htaccess here (remove passwords if there are any)?
Thanks again for still trying to help me. This is really important for me I've been like crazy these 2 days trying to find solution. And all this time Google show more and more errors.

Not followed 301 respond code!

Here is my htaccess:

Options -MultiViews +FollowSymlinks -Indexes

#
# If mod_security is enabled, attempt to disable it.
# - Note, this will work on the majority of hosts but on
#   MediaTemple, it is known to cause random Internal Server
#   errors. For MediaTemple, please remove the block below
#
<IfModule mod_security.c>
	# Turn off mod_security filtering.
	SecFilterEngine Off

	# The below probably isn't needed, but better safe than sorry.
	SecFilterScanPOST Off
</IfModule>

#
# MyBB "search engine friendly" URL rewrites
# - Note, for these to work with MyBB please make sure you have
#   the setting enabled in the Admin CP and you have this file
#   named .htaccess
#
<IfModule mod_rewrite.c>
	RewriteEngine on
	
	# Some hosts require RewriteBase to make RewriteRules work.
RewriteBase /

# Google SEO workaround for search.php highlights:
# Make this rule the first rewrite rule in your .htaccess!
RewriteRule ^([^&]*)&(.*)$ http://letsforum.com/$1?$2 [L,QSA,R=301]


# Google SEO Sitemap:
RewriteRule ^sitemap\-([^./]+)\.xml$ misc.php?google_seo_sitemap=$1 [L,QSA,NC]

# Google SEO URL Forums:
RewriteRule ^Forum\-([^./]+)$ forumdisplay.php?google_seo_forum=$1 [L,QSA,NC]

# Google SEO URL Threads:
RewriteRule ^Thread\-([^./]+)$ showthread.php?google_seo_thread=$1 [L,QSA,NC]

# Google SEO URL Announcements:
RewriteRule ^Announcement\-([^./]+)$ announcements.php?google_seo_announcement=$1 [L,QSA,NC]

# Google SEO URL Users:
RewriteRule ^User\-([^./]+)$ member.php?action=profile&google_seo_user=$1 [L,QSA,NC]

# Google SEO URL Calendars:
RewriteRule ^Calendar\-([^./]+)$ calendar.php?google_seo_calendar=$1 [L,QSA,NC]

# Google SEO URL Events:
RewriteRule ^Event\-([^./]+)$ calendar.php?action=event&google_seo_event=$1 [L,QSA,NC]

# Google SEO 404:
ErrorDocument 404 /misc.php?google_seo_error=404

# www to non 301 redirect:
rewritecond %{http_host} ^www.letsforum.com [nc]
rewriterule ^(.*)$ http://letsforum.com/$1 [r=301,nc]
	
# HERE GOES DEFAULT MYBB REWRITE RULES!!!!!!!!!!

	<IfModule mod_env.c>
		SetEnv SEO_SUPPORT 1
	</IfModule>
</IfModule>

#
# If Apache is compiled with built in mod_deflade/GZIP support
# then GZIP Javascript, CSS, HTML and XML so they're sent to
# the client faster.
#
<IfModule mod_deflate.c>
	AddOutputFilterByType DEFLATE application/javascript text/css text/html text/xml
</IfModule>
Hmm. It seems correct. I'm clueless as to why it sends a 301 to forumdisplay.php when the forum doesn't exist. This gives a 301 to forumdisplay.php and then to index.php, and I don't think Google likes chained 301 redirects...
Any idea how to fix it?

Do you know how can I contact the SEO plugin author so that he could fix the issue please?

If you open google_seo/redirect.php file there is some 301 redirect code maybe thre is a bug?

function google_seo_redirect_header

The strange thing is that many 301 redirects work great but some are not!
Post in the Google SEO plugin release thread.

I'm not fully sure if Google SEO is the problem for you or not...
Pages: 1 2 3