Score:0

Nginx : rewrite rule with multiple urls

us flag

Want to rewrite nginx with setup such as www.example.com/abc/xyz/test/

redirect to www.example.com/abc/xyz/test.php So want to make an rewrite rule which will work for all pages with that url like so i tried this one which works

 location ~* /abc/xyz/.*/$
        {
            rewrite ^/abc/xyz/.*/$  /abc/xyz/test.php last;
        }

this rule works but it always redirect to test.php want to make it dynamic so that it will also work for test2.php test3.php when in url it will be like www.example.com/abc/xyz/test2/ and so on as we have 100 pages so i need to write 100 rules if no solution found. Any help will be appreciate.

Score:0
in flag

try_files should be sufficient.

location / {
    try_files $uri $uri.php;
}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.