MyBB Community Forums

Full Version: Google SEO rewrites don't seem to work with nginx
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, everyone!

Recently I switched from Apache to nginx.
I successfully moved my forums onto new server. The only thing I cant make work is Google SEO.
I even reinstalled it, reconfigured it and repopulated the mybb_google_seo table. Still nothing.

Here's the .htaccess code plugin wants me to use:

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://podziemieopowiadan.pl/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\-([^./]+)\.html$ forumdisplay.php?google_seo_forum=$1 [L,QSA,NC]

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

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

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

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

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

Here's my Virtual server configuration:

server {
	server_name www.podziemieopowiadan.pl;
	listen 80;

	return 301 http://podziemieopowiadan.pl/index.php;
}
 
 
server 
{
	server_name podziemieopowiadan.pl;
	listen 80;

	access_log /var/log/nginx/podziemieopowiadan-pl_access_log;
	error_log /var/log/nginx/podziemieopowiadan-pl_error_log;
	root /var/www/domains/podziemieopowiadan-old;
	
	index index.php;
	
	allow 188.127.246.50;
	allow 188.127.242.122;
	allow 204.93.240.0;
	allow 204.93.177.0;
	allow 199.27.128.0;
	allow 173.245.48.0;
	allow 103.21.244.0;
	allow 103.22.200.0;
	allow 103.31.4.0;
	allow 141.101.64.0;
	allow 108.162.192.0;
	allow 190.93.240.0;
	allow 188.114.96.0;
	allow 197.234.240.0;
	allow 198.41.128.0;
	allow 162.158.0.0;

	include global.conf;
	
	location /forum/{
		index index.html index.php;
		
		rewrite ^/([^&]*)&(.*)$ http://podziemieopowiadan.pl/forum/$1?$2 permanent;

		rewrite ^/((?i)sitemap-([^./]+)\.xml)$ /forum/misc.php?google_seo_sitemap=$2 last;
		rewrite ^/((?i)forum-([^./]+)\.html)$ /forum/forumdisplay.php?google_seo_forum=$2 last;
		rewrite ^/((?i)thread-([^./]+)\.html)$ /forum/showthread.php?google_seo_thread=$2 last;
		rewrite ^/((?i)announcement-([^./]+)\.html)$ /forum/announcements.php?google_seo_announcement=$2 last;
		rewrite ^/((?i)user-([^./]+)\.html)$ /forum/member.php?action=profile&google_seo_user=$2 last;
		rewrite ^/((?i)calendar-([^./]+)\.html)$ /forum/calendar.php?google_seo_calendar=$2 last;
		rewrite ^/((?i)event-([^./]+)\.html)$ /forum/calendar.php?action=event&google_seo_event=$2 last;
	}

	location ~ \.php$
	{
               try_files $uri =404;
               include fastcgi_params;
               fastcgi_pass unix:/var/run/php5-fpm.sock;
			   fastcgi_param REDIRECT_URL $request_uri;
    }

}


I'm running on 1.6.16, with Google SEO 1.6.5
It all was working fine on Apache, but the rewrites on nginx don't seem to work.
Google SEO plugin has a sample rewrite rules file for NGINX - have you seen it ..
Yes... I tried avery combination based on this sample... With the same effect :p


#edit
Forget it. adding folder name to the begging fixed it. Wonder why it failed before, Perhaps I had something more wrong with syntax. Sorry for taking your time.
well maybe someone else have the same error and this thread helps. Thanks for tell wheres the error and solution xD, many novice users dont know even the click to apply changes on functions.php file by the google seo plugin.
(2015-01-24, 02:01 PM)Nidrax Wrote: [ -> ]Yes... I tried avery combination based on this sample... With the same effect :p


#edit
Forget it. adding folder name to the begging fixed it. Wonder why it failed before, Perhaps I had something more wrong with syntax. Sorry for taking your time.

Nidrax, would mind sharing your rewrite rules? I having trouble with this. I dont understand where to add folder name. Sharing your write rules would greatly help me...please Confused