0
votes

How do you do nginx rewrite rule to convert

example.com/?subtopic=forum&action=show_board&id=1

into this

example.com/forum/board/1

or this

example.com/?subtopic=characters&name=Eternal

into this

example.com/characters/Eternal

I've found and tried to play around with this code

location / {
            rewrite ^/subtopic/(.*)$ /?subtopic=$1 last;
    }

but it doesnt work (i'm really a newbie into rewriting)

1
Changed rule to this rewrite ^(.*)$ /?subtopic=characters&name=$1 last; and its a step, it recognize something in a link, but when i try to see character page, it says Character /Eternal does not exist. - Rafal Olszewski

1 Answers

0
votes

You may try these rules:

rewrite /(.*)/(.*)/(\d+) /?subtopic=$1&action=show_$2&id=$3 last;
rewrite /(.*)/(.*)       /?subtopic=$1&name=$2 last;