MyBB Community Forums

Full Version: (Google SEO once more): clash between wordpress .htaccess and forum .htaccess
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Google SEO url rewrite fails on live system

I have wordpress installed at the root level. then, in root, I have forum directory in which myBB 1.8.4 resides. Now there is apparently a clash between the htaccess of wordpress and the htaccess of mybb inside the /forum/ directory?

Due to this, the forum urls aren't rewrited by google-seo plugin. if we try to open forum, then it redirects to the homepage (wordpress-page).

Also I have to mention that board url is set to (no www): http://crypto.country/forum

We already posted some more background information here http://community.mybb.com/thread-170089-...pid1155307 .

I just can't believe that such a basic setup (Wordpress www and MyBB forum) gives so many problems to us, while others (including the manual) show it's rather easy (up to a point) to install Google SEO plugin :/

Sorry we keep pressing this matter... I just ♥ me some SEO friendly URLs Sad

Peace!

Devvie
if you have your mybb installation installed at /forum, shouldn't your .htaccess rewrites for mybb be inside of the /forum directory?
Yes, we think so too. But it doesn't work for us :/
(2015-05-03, 08:50 PM)bitcoin Wrote: [ -> ]Yes, we think so too. But it doesn't work for us :/

if you moved the google seo rewrites to an .htaccess file inside /forum, did you change your RewriteBase  from

RewriteBase /forum

to

RewriteBase /

and then adjusting the first rewrite accordingly?

RewriteRule ^([^&]*)&(.*)$ http://yoursite.com/$1?$2 [L,QSA,R=301]
(2015-05-03, 08:54 PM)andrewjs18 Wrote: [ -> ]did you change your RewriteBase  from

RewriteBase /forum

to

RewriteBase /

and then adjusting the first rewrite accordingly?



RewriteRule ^([^&]*)&(.*)$ http://yoursite.com/$1?$2 [L,QSA,R=301]

Hmm... Good one. I think we both assumed that the .htaccess in /forum/ should have "/forum" as value for RewriteBase, not "/"... But I can understand your reasoning here if it works like some kind of sandbox... With '/forum' now being top "root" '/'... Let me check some stuff Smile

yeah, this is what we used...

# Some hosts need a RewriteBase specification.
RewriteBase /forum/

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

PS: do we really need to change
RewriteRule ^([^&]*)&(.*)$ http://crypto.country/forum/$1?$2 [L,QSA,R=301]

to
RewriteRule ^([^&]*)&(.*)$ http://crypto.country/$1?$2 [L,QSA,R=301]

While I sort of can make sense of 'rewritebase /forum/' to 'rewritebase /', I don't really understand the new RewriteRule

Ok, let me try to go through it step by step... See where I start to mess up...

So, I disabled Google SEO plugin.

I set "Enable search engine friendly URLs?" to 'automatic' and "Enable search engine friendly URLs in Archive?" to "No".

I renamed htaccess.txt in crypto.country/forum/ to .htaccess .

If I now go to crypto.country/forum, I get this error:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I rename crypto.country/forum/.htaccess to /forum/.htaccess.tmp so I can access Admin CP once more. There I enable the option "Enable search engine friendly URLs in Archive?" before re-activating .htaccess (still without any modifications). Again, crypto.country/forum gives above error message (404).

I then renamed /.htaccess to /.htaccess-testing to be sure that /.htaccess wasn't interrupting /forum/.htaccess . Again, 404 for the forum. BUT after waiting a bit, I now can open crypto.country/forum once more. All looks good; when I hover above a link, I can see the URLs have changed to search engine friendly URL naming system. CLICKING the links... Well, that gives a CloudFlare link not found error page. IF I now enable /forum/.htaccess too, I will get the error I quoted in the code box above...

Contents of that .htaccess file:
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
	RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA]
	RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]

	RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
	RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
	RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
	RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
	RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
	RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
	RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]

	RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]

	RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]

	RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]

	RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
	RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
	RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
	RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]

	RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]

	<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>

So before throwing myself at Google's SEO URLs... I think we should first start looking at this problem. The solution might explain the problems with Google SEO plugin too...
sorry, I'm not an .htaccess expert by any stretch of the word. someone who is more experienced will have to lend you a hand. if you have root access, is mod_rewrite enabled?

as an aside, adding rewrite rules to your apache config for your site makes it faster to process than using .htaccess rules AFAIK. might be something you investigate further down the road.
I asked for .htaccess details and howto's here http://community.mybb.com/thread-99435-p...pid1156461

I'm starting to believe it's not a Wordpress / MyBB .htaccess clash, but something else entirely. Even if I upload non-SEO related .htaccess files, we get error 500... I asked my hoster for support now too (cheweb.it).

Grmbl  Confused

Devvie : )

Answer by host:
Quote:i can see different .htaccess file into your public_html and the problem that you see with 500 internal server error, are wrong directive present into these file when they are activated.

I have copied .htaccess (active ) rules and created a new .htaccess file and there's not error. So you need understand what need insert in a .htaccess file and configuring it correctly. I remember you that is possibile have only a .htaccess file in a public_html, so every rules you need have to be there.

Translation: we are amateurs and should get our orange together... Sigh.

So testing, once more, from scratch...

1. Google SEO .htaccess in /public_html/
RewriteEngine on

# Some hosts require RewriteBase to make RewriteRules work.
RewriteBase /forum/

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

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

# 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]

If I now enable Google SEO plugin, it sort of works: I can see that my sub board's URLs have changed to SEO friendly ones. Clicking the links gives an error, still:
You do not have permission to access this page. This could be because of one of the following reasons:
Your account has either been suspended or you have been banned from accessing this resource.
You do not have permission to access this page. Are you trying to access administrative pages or a resource that you shouldn't be? Check in the forum rules that you are allowed to perform this action.
Your account may still be awaiting activation or moderation. (Resend Activation Code)
You have accessed this page directly rather than using appropriate forms or link.

You are currently logged in with the username: 'devnullius'
Other things to try:

Search crypto.country: sub board name [Google Search Button]

This is after I selected Apply changes to core files.

So I now, with Google SEO plugin still active but not applied to core files, tried the following .htaccess (made by my coder), also in /html_public/:
# EXAMPLE .htaccess FOR MYBB WITH GOOGLE SEO URL

# -------------------------------------------------------------------
# This file is identical to MyBB's htaccess.txt example file,
# with rewrite rules for a standard Google SEO install added.
#
# Before using this file please make sure to:
#
#   - replace /MyBB/ with your forum folder, e.g. / or /forum/
#   - replace yoursite/MyBB with your forum URL
#   - name the file '.htaccess' (starting with the dot, no .txt)
#
# Alternatively you can add the required rewrite rules to your
# existing .htaccess, the specific rules required will be displayed
# on the plugin status page once Google SEO URL is enabled.
# -------------------------------------------------------------------

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 need a RewriteBase specification.
RewriteBase /forum/

# Google SEO workaround for search.php highlights:
# Make this rule the first rewrite rule in your .htaccess!
RewriteRule ^([^&]*)&(.*)$ http://crypto.country/forum/$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 /forum/misc.php?google_seo_error=404

# Default MyBB Rewrite Rules:
RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA]
RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]

RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]

RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]

RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]

RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]

RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)\.html$ calendar.php?action=yearview&calendar=$1&year=$2 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]

RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]

<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/x-javascript text/css text/html text/xml
</IfModule>

That gives a blank page with a 500 error... That's even worse!
Quote:Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Same .htaccess as above, but uploaded after applying the changes to the core files gives the exact same result, except that forum tries to use the friendly URLs by Google again...

So I now tried a new .htaccess in /public_html, containing only the MyBB rewrite rules and Google SEO *not* applied to the core files...:
# Default MyBB Rewrite Rules:

RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA]
RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]

RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]

RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]

RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]

RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]

RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)\.html$ calendar.php?action=yearview&calendar=$1&year=$2 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]

RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]

<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/x-javascript text/css text/html text/xml
</IfModule>

Again, same result: page 500 : -( Which gives the following conclusion: Google SEO isn't effectively rewriting the URLs, only MyBB thinks the URLs are with friendly names... And something is *really* wrong with the MyBB rewrite rules!

---
Server and Optimization Options
Enable search engine friendly URLs? Automatic
Enable search engine friendly URLs in Archive? Yes
---
Post-edit: Kaya solved it - with exactly the same .htaccess as tested by me here... I really don't get it Sad It should have worked, but didn't :/
Problem fixed. Here's what the issue was:

no .htaccess were found, nor the content was in that file. Also multiple .htaccess files was on the server (such as: .htaccess new) and so on.
I confirm it works, though I still don't get it. The multiple (renamed) .htaccess files are still all there; remnants of earlier testing.

The .htaccess is placed in /public_html/forum/

Contents:
RewriteEngine on

# Some hosts require RewriteBase to make RewriteRules work.
RewriteBase /forum/

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

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

# 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]
Pages: 1 2