Score:0

Nginx equivalent for apache mod_rewrite rule

zw flag

My script is hosted on centos 7 apache server, with below htaccess:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Now we have migrated the script to a ubuntu 20 server, with nginx webservice. The nginx conf has the following settings:

rewrite ^/(.*.php)(/)(.*)$ /$1?file=/$3 last;

try_files $uri $uri/ /index.php?$args;
index index.php index.html;

However this does not work for my script.

How can I rewrite this htaccess information for nginx conf instead?

Any help is much appreciated.

us flag
Please add details about "it does not work". What is the request you are making? What is the expected result? What is the actual result?
Giuseppe De Paola avatar
eu flag
Have you solved? I'm interested on how
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.