Score:0

nginx rewrite both .php and .html

st flag
oim

Have 2 rules for working files with (html, php) prefix and without.

But working only first rule. If first php, second with html prefix show not found.

if (!-e $request_filename){
    rewrite ^/([^\.]+)$ /$1.php break;
}

if (!-e $request_filename){
    rewrite ^/([^\.]+)$ /$1.html break;
}

If I swap them working with html. How merge to working both. Thanks

Score:0
jp flag

Perhaps you are trying to reinvent try_files with these if conditions?

In that case, this should work:

try_files $uri $uri.php $uri.html;
oim avatar
st flag
oim
This return 404. I try popular rules: if ($request_uri ~ ^/(.*)\.html(\?|$)) { return 302 /$1; } try_files $uri $uri.html $uri/ =404; It not working
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.