Mateus Melo
Mateus Melo

Reputation: 131

What is the nginx equivalent of this htaccess file?

I'm new to nginx and having a hard time trying to convert this htaccess file into readable nginx logic:

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]

The farthest I came up with was this:

location / {
    try_files $uri $uri/ /index.php?uri=$args;
}

What am I doing wrong?

Thanks in advance

Upvotes: 0

Views: 404

Answers (1)

silinxey
silinxey

Reputation: 366

You need both URI and query string arguments, $uri and $args in nginx. Try this:

location / {
    try_files $uri $uri/ /index.php?uri=$uri&$args;
}

Upvotes: 1

Related Questions