Announcement

Collapse
No announcement yet.

nginx rewrites for mod rewrite friendly URLs

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:
            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;
            }
    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 22nd 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.

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

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud customization and demonstration site.
    vBulletin 5 Documentation - Updated every Friday. Report issues here.
    vBulletin 5 API - Full / Mobile
    I am not currently available for vB Messenger Chats.

    Comment

    Working...
    X