I
I
invisii2019-09-13 20:04:24
Nginx
invisii, 2019-09-13 20:04:24

How to convert these Apache redirects to nginx?

Good day. Help convert these htaccess redirects to nginx:

RewriteEngine On
RewriteCond %{THE_REQUEST} \s(\S+)\.html
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html [L]
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^(.*)$ [email protected]%1? [L]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2019-09-13
@invisii

map $args $_at {
    default "@";
    ""      "";
}
server {
    
    location ~ ^(.+)\.html$ {
        return 301 $1$is_args$args;
    }

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

K
ky0, 2019-09-13
@ky0

location / {
  rewrite ^(.*)$ /%1 redirect;
  rewrite ^(.*)$ /$1.html break;
  if ($query_string ~ "^(.+)$"){
    rewrite ^(.*)$ /[email protected]%1? break;
  }
}

https://winginx.com/ru/htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question