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 ^(.*)$ $1@%1? [L]
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;
}
location / {
rewrite ^(.*)$ /%1 redirect;
rewrite ^(.*)$ /$1.html break;
if ($query_string ~ "^(.+)$"){
rewrite ^(.*)$ /$1@%1? break;
}
}