frostschutz / MyBB-Google-SEO

Search Engine Optimization plugin for MyBB.
https://community.mybb.com/thread-202483.html
GNU General Public License v3.0
30 stars 25 forks source link

search.php doesn't highlight more than one word #29

Closed dandv closed 13 years ago

dandv commented 13 years ago

I'm using Google SEO with MyBB 1.6.3 on nginx.

If I understand correctly, this rule needs to be added to the .conf file because otherwise, search.php is appended an ampersand instead of the question mark:

# Google SEO workaround for search.php highlights:
# Make this rule the first rewrite rule in your .htaccess!
rewrite ^/([^&]*)&(.*)$ http://forum.quantifiedself.com/$1?$2 permanent;

The problem I see on my board is that the whole query string gets URL-encoded, including the plus sign between keywords to be highlighted. This causes the highlight to not work.

Example on my board: search.php generates a list of threads or posts with URLs that are incorrect, i.e. have the ampersand:

http://forum.quantifiedself.com/thread-measuring-cognitive-performance&highlight=reaction+time

Then these get rewritten to replace the '&' with '?'. In the process, the + gets URL-encoded to %2B:

http://forum.quantifiedself.com/thread-measuring-cognitive-performance?highlight=reaction%2btime

PS: All I could find relevant to this issue in the enormous thread on community.mybb.com was this post.

frostschutz commented 13 years ago

The post you linked to refers to a separate issue (where & is actually part of a file name before ?, which then gets broken by this crude workaround). It's unfortunate that MyBB appends ?/& blindly to URLs without checking whether ? is already present or not. Not much I can do about it.

Regarding your issue, it seems that nginx rewrite behaviour differs from Apache here. The workaround works fine with Apache's .htaccess, I just tested it. While I do use nginx myself, I can't offer you any support for it, since this plugin officially requires Apache+MySQL to work. Sorry.

You can try changing the MyBB SEF URL setting though; depending on whether SEF URL is set to Yes or No, the broken URLs will either bei url&param or url?param?param. The workaround for the double ? case is implemented in Google SEO Redirect, maybe it will work with Nginx.

Maybe I'll just have to grab the entire page with output buffers and fix things myself. It certainly won't be fixed on MyBB's end.

mrl586 commented 13 years ago

I think that I can reproduce this bug. If I set MyBB SEF to enabled, I see blank page when I try access to page but if I select Automatic detection, I see this page normally.