Current time: 04-23-2014, 10:06 PM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Nginx] Enabling Search Engine Friendly URLs
06-22-2009, 02:03 PM (This post was last modified: 06-22-2009 02:37 PM by frostschutz.)
Post: #1
Pencil [Nginx] Enabling Search Engine Friendly URLs
This user has been denied support. This user has been denied support.
If you are using Nginx instead of Apache web server, this tutorial explains how you can enable MyBB's Search Engine Friendly SEF URLs. Apache users do not need to read this tutorial.

This tutorial does not explain how to install and set up Nginx with PHP from scratch; it is expected that you already have everything up and running, and now all that's left are the SEF URLs.

nginx.conf

First you should make a backup copy of your nginx.conf, so you can go back to your working config in case anything goes wrong.

In the server / location section, add these rewrite rules. Replace /MyBB/ with the directory you have MyBB installed. If your MyBB is installed in a top level domain, replace it with /, if it's in /forum replace it with /forum/ and so on.

Please note that every rewrite statement goes in a single line even if it wraps in your browser here.

Code:
location / {
    # ...your location settings are here...

    rewrite ^/MyBB/forum-([0-9]+)\.html$ /MyBB/forumdisplay.php?fid=$1;
    rewrite ^/MyBB/forum-([0-9]+)-page-([0-9]+)\.html$ /MyBB/forumdisplay.php?fid=$1&page=$2;
    rewrite ^/MyBB/thread-([0-9]+)\.html$ /MyBB/showthread.php?tid=$1;
    rewrite ^/MyBB/thread-([0-9]+)-page-([0-9]+)\.html$ /MyBB/showthread.php?tid=$1&page=$2;
    rewrite ^/MyBB/thread-([0-9]+)-lastpost\.html$ /MyBB/showthread.php?tid=$1&action=lastpost;
    rewrite ^/MyBB/thread-([0-9]+)-nextnewest\.html$ /MyBB/showthread.php?tid=$1&action=nextnewest;
    rewrite ^/MyBB/thread-([0-9]+)-nextoldest\.html$ /MyBB/showthread.php?tid=$1&action=nextoldest;
    rewrite ^/MyBB/thread-([0-9]+)-newpost\.html$ /MyBB/showthread.php?tid=$1&action=newpost;
    rewrite ^/MyBB/thread-([0-9]+)-post-([0-9]+)\.html$ /MyBB/showthread.php?tid=$1&pid=$2;

    rewrite ^/MyBB/post-([0-9]+)\.html$ /MyBB/showthread.php?pid=$1;

    rewrite ^/MyBB/announcement-([0-9]+)\.html$ /MyBB/announcements.php?aid=$1;

    rewrite ^/MyBB/user-([0-9]+)\.html$ /MyBB/member.php?action=profile&uid=$1;

    rewrite ^/MyBB/calendar-([0-9]+)\.html$ /MyBB/calendar.php?calendar=$1;
    rewrite ^/MyBB/calendar-([0-9]+)-year-([0-9]+)\.html$ /MyBB/calendar.php?action=yearview&calendar=$1&year=$2;
    rewrite ^/MyBB/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /MyBB/calendar.php?calendar=$1&year=$2&month=$3;
    rewrite ^/MyBB/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /MyBB/calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
    rewrite ^/MyBB/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /MyBB/calendar.php?action=weekview&calendar=$1&week=$2;

    rewrite ^/MyBB/event-([0-9]+)\.html$ /MyBB/calendar.php?action=event&eid=$1;
}

Restart Nginx so the changes can take effect.

MyBB settings

In Admin CP, go to 'Configuration' -> 'Server and Optimization options' and set 'Enable search engine friendly URLs?' to 'Enabled'.
(The auto detect option will not work with Nginx.)

Go back into your forum and test if the MyBB SEF URLs work.

Troubleshooting
  • Nginx refuses to start
    You probably made an error when editing the config file; Nginx should tell you where the error is, correct it.
  • I get 404 errors when clicking on thread / forum links
    Your rewrite rules are not working. Maybe you used the wrong path (in the example /MyBB/). Replace it with the correct path, for example / or /forum/. Also check if you installed Nginx with PCRE and HttpRewriteModule support.

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz
Find all posts by this user
Quote this message in a reply
01-09-2010, 04:55 PM (This post was last modified: 01-09-2010 04:58 PM by FBI.)
Post: #2
RE: [Nginx] Enabling Search Engine Friendly URLs
I'll bookmarks Frost.
Thanks..

It would be nice, if your Google SEO Mod has ability to switch between Nginx and Apache Rewrite. Or include it this totorial file into Smile
also this one http://community.mybboard.net/thread-51759.html

New Beta Portal from MyBB Indonesia to get local support
My 'Simple' Unique Plugin here Smile
Find all posts by this user
Quote this message in a reply
01-09-2010, 05:06 PM
Post: #3
RE: [Nginx] Enabling Search Engine Friendly URLs
This user has been denied support. This user has been denied support.
Google SEO already includes example rewrite rules for lighttpd and nginx, it's just not officially supported or recommended. If you have problems with it or if you change to custom URL scheme in the Google SEO settings, you have to adapt the example rewrite rules by yourself, I don't have the time to do this for you. Sorry if this sounds harsh, but I'm spending more than enough time supporting this plugin as it is...

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz
Find all posts by this user
Quote this message in a reply
01-09-2010, 10:50 PM
Post: #4
RE: [Nginx] Enabling Search Engine Friendly URLs
I mean, not applied on your mod. I know How hard the code is Smile
But, only information that your tips apply on Default MyBB SEO Friendly URL

Thanks

New Beta Portal from MyBB Indonesia to get local support
My 'Simple' Unique Plugin here Smile
Find all posts by this user
Quote this message in a reply
01-10-2010, 03:49 AM
Post: #5
RE: [Nginx] Enabling Search Engine Friendly URLs
This user has been denied support. This user has been denied support.
You mean like this? Huh

(06-22-2009 02:03 PM)frostschutz Wrote:  this tutorial explains how you can enable MyBB's Search Engine Friendly SEF URLs.

You can do both, MyBB SEF URLs, or Google SEO URLs, or something entirely different... once you know how to do rewrites with lighttpd/nginx you can do rewrites for pretty much anything, the concept is the same, the syntax slightly different from .htaccess.

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz
Find all posts by this user
Quote this message in a reply
01-11-2010, 02:14 PM
Post: #6
RE: [Nginx] Enabling Search Engine Friendly URLs
Thank you for this tutorial.

[Image: 468x602b.png]
Find all posts by this user
Quote this message in a reply
01-22-2014, 02:13 AM
Post: #7
RE: [Nginx] Enabling Search Engine Friendly URLs
I realize this is extremely old, but I've been working with nginx and this has helped a lot. I was about to pull my hair out.

The Elder Scrolls Online Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
02-27-2014, 11:14 PM
Post: #8
RE: [Nginx] Enabling Search Engine Friendly URLs
how to enable google seo RewriteRule to Nginx Huh --help

* SunDi3yansyah Newbie MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
02-28-2014, 04:31 PM
Post: #9
RE: [Nginx] Enabling Search Engine Friendly URLs
(02-27-2014 11:14 PM)SunDi3yansyah Wrote:  how to enable google seo RewriteRule to Nginx Huh --help

http://lmgtfy.com/?q=mybb+%2B+nginx+%2B+google+seo

https://github.com/frostschutz/MyBB-Goog...-nginx.txt

Visit this user's website Find all posts by this user
Quote this message in a reply
03-02-2014, 04:36 PM (This post was last modified: 03-02-2014 04:49 PM by SunDi3yansyah.)
Post: #10
RE: [Nginx] Enabling Search Engine Friendly URLs
(02-28-2014 04:31 PM)Euan T Wrote:  
(02-27-2014 11:14 PM)SunDi3yansyah Wrote:  how to enable google seo RewriteRule to Nginx Huh --help

http://lmgtfy.com/?q=mybb+%2B+nginx+%2B+google+seo

https://github.com/frostschutz/MyBB-Goog...-nginx.txt

Thanks Euan T Big Grin

I addition to the Google Seo page 404

Code:
error_page 404 /misc.php?google_seo_error=404;

* SunDi3yansyah Newbie MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication