I need to convert a .htaccess redirect to Nginx conf.
Here is the .htaccess
Redirect 301 /wp-content/plugins/zendesk-for-woocommerce/api/redirect-test1.html /wp-content/plugins/zendesk-for-woocommerce/api/redirect-test2.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
DirectoryIndex index.html index.htm index.php index.shtml
Here is the relevant section of my Nginx config
location / {
root /var/www/vhosts/sitename/httpdocs;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
According to the guide I found online I changed it to:
location / {
root /var/www/vhosts/sitename/httpdocs;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
if (!-e $request_filename){
rewrite ^(.*)$ /$env_base index.php break;
}
}
I get the error:
nginx: [emerg] invalid number of arguments in "rewrite" directive in /etc/nginx/conf.d/sitename.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed