nginx rewrites for mod rewrite friendly URLs

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sub_ubi
    Member
    • Dec 2004
    • 77
    • 3.0.3

    nginx rewrites for mod rewrite friendly URLs

    Since there's no official nginx config for VB4, I figured I'd post my rewrites, which are working fine so far.

    I'm running the full VB4 suite, with my CMS in the root folder (using the CMS stub folder - www.example.com) and my forums at /forums (www.example.com/forums)

    Code:
    [noparse]        location / {
                    #for vbulletin
                     try_files $uri $uri/ @rewrite;
            }
    
            location @rewrite {
                # Forum
                rewrite /widget/config/.*   /forums/widget.php?r=config/$1&$query_string last;
                rewrite /content/?(.*)                   /forums/content.php?page$1           last;
                rewrite /showthread.php/.*             /forums/showthread.php?$uri&$args      last;
                rewrite /threads/.*                    /forums/showthread.php?$uri&$args      last;
                rewrite /forumdisplay.php/.*              /forums/forumdisplay.php?$uri&$args    last;
                rewrite /member.php/.*             /forums/member.php?$uri&$args          last;
                rewrite /members/.*                /forums/member.php?$uri&$args              last;
                rewrite /blogs/.*               /forums/blog.php?$uri&$args            last;
                rewrite /entries/.*             /forums/entry.php?$uri&$args           last;
                rewrite /list/.*                  /forums/list.php?$uri&args           last;
                rewrite /content.php/.*         /forums/content.php?$uri&$args                last;
                rewrite /forums/.*              /forums/forumdisplay.php?$uri&$args    last;
                rewrite /content/.*             /content.php?$uri&$args                last;
                # MVC
                rewrite ^/(?:(.*?)(?:/|$))(.*|$)$       /$1.php?r=$2                    last;
            }[/noparse]
    Just hoping it saves someone a few hours of frustration.

    If you have any suggestions to make it cleaner, let me know and I'll edit them in.
    Last edited by sub_ubi; Sun 22 Jan '17, 3:58pm. Reason: I had to use noparse tags to make this post work. Without them, writing @rewrite - even in the code tags - turned the word into a link to a forum user. VB5 is not for me.
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 73981

    #2
    Thank you for your contribution.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...