Convert htacces to nginx

1

Good afternoon I'm migrating an Apache server to Nginx and I have a project with some rules in .htaccess that I do not know how to convert to Nginx.

they are:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule .* http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^(.*)/*sitemap.xml$ app.php?path=sitemap.xml [L]

RewriteCond %{REQUEST_URI} .(jpg|jpeg|png|gif)
RewriteCond %{HTTPS}s ^on(s)|

RewriteRule ^imagem/([/a-zA-Z0-9._-]+)$ http%1://outrodominio.com.br/up$

RewriteCond %{REQUEST_URI} !.(jpg|jpeg|png|gif|css|js|zip|log|eot|ttf|woff|svg$
RewriteRule ^(.*)$ app.php?path=$1 [QSA,L]

I need help creating these rules in Nginx

    
asked by anonymous 11.11.2015 / 00:24

1 answer

0

See if it helps:

# non-www to www
server {
  listen       80;
  listen       443 ssl;
  server_name  seudominio.com.br;

  return 301 $server_protocol://www.$server_name$request_uri;
}

server {
  listen       80;
  listen       443 ssl;
  server_name  www.seudominio.com.br;

  location / {

    if (-f $request_filename) {
      break;
    }

    if (-d $request_filename) {
      break;
    }

    rewrite ^(.+)$ /app.php?path=$1 last;
  }

  location /imagem/ {

    rewrite ^(.+)$ $server_protocol://outrodominio.com.br/up$1 last;
  }
}
    
29.04.2016 / 20:23