From adb9fd43daca0087e78c69f240f778bd3da7606a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=83=BC=E3=82=A4=E3=83=84?= Date: Sat, 9 Dec 2017 02:46:18 -0600 Subject: [PATCH 1/6] Update rewrite-nginx.txt --- rewrite-nginx.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rewrite-nginx.txt b/rewrite-nginx.txt index 1cccaf3..54f27c5 100644 --- a/rewrite-nginx.txt +++ b/rewrite-nginx.txt @@ -32,3 +32,11 @@ Here is an example of what nginx rules for Google SEO look like: # Google SEO URL Events: rewrite ^/MyBB/((?i)Event-([^./]+))$ /MyBB/calendar.php?action=event&google_seo_event=$2; + + # In the event the server is using both NGINX and Apache, + # the URLs should have `rewritten` set to `1`. + + # If you're just copying and pasting, uncomment the lines below + # if ($is_args) { + # set $args "$args&rewritten=1"; + # } From 0467354613034a086b647bef672830335adbdda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=83=BC=E3=82=A4=E3=83=84?= Date: Sat, 9 Dec 2017 02:47:30 -0600 Subject: [PATCH 2/6] Update redirect.php --- inc/plugins/google_seo/redirect.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inc/plugins/google_seo/redirect.php b/inc/plugins/google_seo/redirect.php index 013a1f4..712394f 100644 --- a/inc/plugins/google_seo/redirect.php +++ b/inc/plugins/google_seo/redirect.php @@ -74,6 +74,13 @@ function google_seo_redirect_hook() // Never touch posts. return; } + + $rewritten = $mybb->get_input('rewritten', MyBB::INPUT_INT); + if ($rewritten) + { + // The URLs were already rewritten by the front-end webserver + return; + } // Build the target URL we should be at: switch(THIS_SCRIPT) From 2006b9d74bdb9808c40e2e858460c14576eb90a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=83=BC=E3=82=A4=E3=83=84?= Date: Sat, 9 Dec 2017 02:56:49 -0600 Subject: [PATCH 3/6] Update url.php --- inc/plugins/google_seo/url.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/plugins/google_seo/url.php b/inc/plugins/google_seo/url.php index 651a652..107f66e 100644 --- a/inc/plugins/google_seo/url.php +++ b/inc/plugins/google_seo/url.php @@ -925,7 +925,7 @@ function google_seo_url_cache($type, $id) } // Return the cached entry for the originally requested type and id. - return $google_seo_url_cache[$type][$id]; + return $settings['bburl'] . '/' . $google_seo_url_cache[$type][$id]; } /* From 4d04e6e8341b58bac574e517cedf9309da2ac3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=83=BC=E3=82=A4=E3=83=84?= Date: Sat, 9 Dec 2017 03:24:16 -0600 Subject: [PATCH 4/6] Update plugin.php --- inc/plugins/google_seo/plugin.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/inc/plugins/google_seo/plugin.php b/inc/plugins/google_seo/plugin.php index 638e7e0..261e846 100644 --- a/inc/plugins/google_seo/plugin.php +++ b/inc/plugins/google_seo/plugin.php @@ -1197,6 +1197,23 @@ function google_seo_plugin_apply($apply=false) '}', ), ); + + // build_profile_link + $edits[] = array( + 'search' => array('return "settings[\'bburl\']}/".get_profile_link($uid)."\\"{$target}{$onclick}>{$username}";'), + 'before' => array( + 'if(function_exists("google_seo_url_profile"))', + '{', + ' $link = google_seo_url_profile($uid);', + '', + ' if ($link)', + ' {', + ' return "{$username}";', + ' }', + '}', + ), + ); + } if($settings['google_seo_url_announcements']) From 0f3e4ee0d4268d56ad7bac549b465df26d8b35ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=83=BC=E3=82=A4=E3=83=84?= Date: Sat, 9 Dec 2017 03:29:02 -0600 Subject: [PATCH 5/6] Update rewrite-nginx.txt --- rewrite-nginx.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/rewrite-nginx.txt b/rewrite-nginx.txt index 54f27c5..5a56614 100644 --- a/rewrite-nginx.txt +++ b/rewrite-nginx.txt @@ -32,11 +32,4 @@ Here is an example of what nginx rules for Google SEO look like: # Google SEO URL Events: rewrite ^/MyBB/((?i)Event-([^./]+))$ /MyBB/calendar.php?action=event&google_seo_event=$2; - - # In the event the server is using both NGINX and Apache, - # the URLs should have `rewritten` set to `1`. - - # If you're just copying and pasting, uncomment the lines below - # if ($is_args) { - # set $args "$args&rewritten=1"; - # } + From 8151b700bfc239b4e27d0e100d5232b6b2827a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=83=BC=E3=82=A4=E3=83=84?= Date: Sat, 9 Dec 2017 03:32:06 -0600 Subject: [PATCH 6/6] Create rewrite-nginx-apache.txt --- rewrite-nginx-apache.txt | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 rewrite-nginx-apache.txt diff --git a/rewrite-nginx-apache.txt b/rewrite-nginx-apache.txt new file mode 100644 index 0000000..eda91f1 --- /dev/null +++ b/rewrite-nginx-apache.txt @@ -0,0 +1,48 @@ +A tutorial for getting rewrite rules (MyBB SEF style) work with nginx: + + http://community.mybboard.net/thread-51764.html + +The same method can be applied for Google SEO rewrite rules, but you +have to create those rules manually. Google SEO can not detect that +you are not using Apache, and will only generate .htaccess rules. + +Here is an example of what nginx rules for Google SEO look like: + + # Google SEO workaround for search.php highlights: + # Make this rule the first rewrite rule in your .htaccess! + rewrite ^/MyBB/([^&]*)&(.*)$ http://yoursite/MyBB/$1?$2 permanent; + + # Google SEO Sitemap: + rewrite ^/MyBB/((?i)sitemap-([^./]+)\.xml)$ /MyBB/misc.php?google_seo_sitemap=$2 last; + + # Google SEO URL Forums: + rewrite ^/MyBB/((?i)Forum-([^./]+))$ /MyBB/forumdisplay.php?google_seo_forum=$2 last; + + # Google SEO URL Threads: + rewrite ^/MyBB/((?i)Thread-([^./]+))$ /MyBB/showthread.php?google_seo_thread=$2 last; + + # Google SEO URL Announcements: + rewrite ^/MyBB/((?i)Announcement-([^./]+))$ /MyBB/announcements.php?google_seo_announcement=$2 last; + + # Google SEO URL Users: + rewrite ^/MyBB/((?i)User-([^./]+))$ /MyBB/member.php?action=profile&google_seo_user=$2 last; + + # Google SEO URL Calendars: + rewrite ^/MyBB/((?i)Calendar-([^./]+))$ /MyBB/calendar.php?google_seo_calendar=$2 last; + + # Google SEO URL Events: + rewrite ^/MyBB/((?i)Event-([^./]+))$ /MyBB/calendar.php?action=event&google_seo_event=$2 last; + + # In the event the server is using both NGINX and Apache, + # the URLs should have `rewritten` set to `1`. + + # Sets rewritten so that when the rewritten URL is proxied to Apache, + # the plugin won't try to redirect the user (causing an infinite loop, + # by redirecting to the SEO url, which is rewritten by NGINX and proxied to + # Apache, then redirected, etc.) + if ($is_args) { + set $args "$args&rewritten=1"; + } + + # Proxy pass below + proxy_pass http://127.0.0.1:8001$uri$is_args$args