Advertisement:

Author Topic: pretty urls + nginx - SOLVED  (Read 9227 times)

Offline TimothyT

  • Semi-Newbie
  • *
  • Posts: 33
pretty urls + nginx - SOLVED
« on: March 19, 2010, 12:39:28 PM »
for reference, all the url rewriting i found didn't cover the rewriting of actions such as help/manage etc, so, here's the solution for nginx i'm using now which seems to be fine. put inside a location / { ... }

Code: [Select]
# actions
rewrite ^/(activate|admin|announce|ban|boardrecount|buddy|calendar|cleanperms)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(collapse|convertentities|convertutf8|coppa|deletemsg|detailedversion|display|dlattach)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(dumpdb|editpoll|editpoll2|featuresettings|featuresettings2|findmember|help|helpadmin)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(im|jsoption|jsmodify|lock|lockVoting|login|login2|logout)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(maintain|manageattachments|manageboards|managecalendar|managesearch|markasread|membergroups|mergetopics)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(mlist|modifycat|modifykarma|modlog|movetopic|movetopic2|news|notify)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(notifyboard|optimizetables|packageget|packages|permissions|pgdownload|pm|post)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(post2|postsettings|printpage|profile|profile2|quotefast|quickmod|quickmod2)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(recent|regcenter|register|register2|reminder|removetopic2|removeoldtopics2|removepoll)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(repairboards|reporttm|reports|requestmembers|search|search2|sendtopic|serversettings)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(serversettings2|smileys|smstats|spellcheck|splittopics|stats|sticky|theme)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(trackip|about:mozilla|about:unknown|unread|unreadreplies|viewErrorLog|viewmembers|viewprofile)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(verificationcode|vote|viewquery|who|\.xml)/?$ "/index.php?pretty;action=$1" last;

# boards + topics
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ /index.php?pretty%3Bboard=$1.0 last;
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/[0-9]?/?$ /index.php?pretty%3Bboard=$1.$2 last;
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ /index.php?pretty%3Bboard=$1%3Btopic=$2.0 last;
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/[0-9]?/?$ /index.php?pretty%3Bboard=$1%3Btopic=$2.$3 last;

as a note, the rewrites for the actions are enclosed in quotes because nginx really does not like the semicolon in the urls

Offline Kill Em All

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,144
  • Gender: Male
  • Something has to go wrong. Just has to.
    • KEAGaming
Re: pretty urls + nginx - SOLVED
« Reply #1 on: March 24, 2010, 09:57:36 PM »
Marking solved as it is a tip.

thanks for the tip by the way.
My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

Offline Cola-Coca

  • SMF Hero
  • ******
  • Posts: 3,599
  • Gender: Male
Re: pretty urls + nginx - SOLVED
« Reply #2 on: May 14, 2014, 09:01:18 PM »
I did not understand you. Can you write me here step by step how to make to work "ngnix and pretty url mod" ?
I LOVE SMF

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,792
    • StoryBB/StoryBB on GitHub
Re: pretty urls + nginx - SOLVED
« Reply #3 on: May 14, 2014, 09:19:05 PM »
We don't generally offer support to sites for warez here. Especially ones that are using an illegal version of SMF while they're at it.

(Evidence: site is using a version of SMF prior to SMF 2.0 final, without copyright.)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Cola-Coca

  • SMF Hero
  • ******
  • Posts: 3,599
  • Gender: Male
Re: pretty urls + nginx - SOLVED
« Reply #4 on: May 15, 2014, 03:05:24 PM »
We don't generally offer support to sites for warez here. Especially ones that are using an illegal version of SMF while they're at it.

(Evidence: site is using a version of SMF prior to SMF 2.0 final, without copyright.)

I moved the signature and the web forum (warez) is not my.
I LOVE SMF

Offline antiemp

  • Semi-Newbie
  • *
  • Posts: 13
Re: pretty urls + nginx - SOLVED
« Reply #5 on: October 12, 2019, 05:13:04 PM »
I have my forum in a subdirectory so had to add the location to my server like this:

Code: [Select]
location /forum {
    # Rules for: actions
    rewrite ^/forum/(activate|admin|announce|attachapprove|badbehavior|buddy|buddies|calendar)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(clock|collapse|coppa|credits|deletemsg|display|dlattach|editpoll)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(editpoll2|refferals|emailuser|findmember|glossary|groups|guest|help)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(helpadmin|httpBL|ignoretopic|im|jseditor|jsmodify|jsoption|lock)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(lockvoting|login|login2|logout|markasread|mergetopics|mlist|moderate)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(modifycat|modifykarma|movetopic|movetopic2|notify|notifyboard|openidreturn|pm)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(post|post2|printpage|profile|quotefast|quickmod|quickmod2|rate)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(recent|register|register2|reminder|removepoll|removetopic2|reporttm|requestmembers)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(restoretopic|rules|search|search2|sendtopic|smstats|suggest|spellcheck)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(splittopics|stats|sticky|staff|theme|trackip|about:mozilla|about:unknown)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(unignoretopic|unread|unreadreplies|verificationcode|viewprofile|vote|viewquery|viewsmfile)/?$ "/forum/index.php?pretty;action=$1" last;
    rewrite ^/forum/(who|\.xml|xmlhttp)/?$ "/forum/index.php?pretty;action=$1" last;

    # Rules for: boards
    rewrite ^/forum/([-_!~*'()$a-zA-Z0-9]+)/?$ "/forum/index.php?pretty;board=$1.0" last;
    rewrite ^/forum/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ "/forum/index.php?pretty;board=$1.$2" last;

    # Rules for: topics
    rewrite ^/forum/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ "/forum/index.php?pretty;board=$1;topic=$2.0" last;
    rewrite ^/forum/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ "/forum/index.php?pretty;board=$1;topic=$2.$3" last;
  }

Offline Irisado

  • Una Luz Brillante en la Oscuridad
  • Doc Coordinator
  • SMF Super Hero
  • *
  • Posts: 10,258
  • Soñando debajo del arco iris
Re: pretty urls + nginx - SOLVED
« Reply #6 on: October 13, 2019, 04:24:31 PM »
While this information may be useful, this topic is more than five years old and marked as solved, so it is now being locked.  Please avoid reviving old topics which have been marked as solved in future.
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente