Score:0

Regular expression for location with slash at the end

ru flag

I have location

location ~ /(apple|club|car|fly|fitness|nivea|nesquik) {
    alias /srv/static-pages/$1.html;

}

I tried

location ~ /(apple|club|car|fly|fitness|nivea|nesquik)(\/)* {
    alias /srv/static-pages/$1.html;

}

But it nothing gives me Nginx gives me files accords uri, but i need work it with '/' at the end and without / Example: example.com/apple example.com/apple/ Now i don't know how i can configure it Help please

Michael Hampton avatar
cz flag
Which URL does not work?
Ivan Shatsky avatar
gr flag
You can try `location ~ ^/(apple|club|car|fly|fitness|nivea|nesquik)/?$ { ... }`
ru flag
example.com/apple - works example.com/apple/ - doesnt work
us flag
What does "doesn't work" mean exactly? What is the exact response?
ru flag
when i try https://example.com/apple - response is 200, its give me apple.html file. So when i try with slash https://example.com/apple / - response is 404. I need that nginx gives me same response when i try request like https://example.com/apple
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.