Apache nginx重写规则/about to index.html?page=about

Apache nginx重写规则/about to index.html?page=about,apache,.htaccess,mod-rewrite,nginx,Apache,.htaccess,Mod Rewrite,Nginx,我的服务器有一些htaccess规则,现在我使用nginx而不是apache 我试图翻译这些规则,我想到了: location /about { rewrite ^/about\.html$ /index.html?page=about; } location /archive { rewrite ^/archive\.html$ /index.html?page=archiveindex; } location /sonic1 { rewrite ^/soni

我的服务器有一些htaccess规则,现在我使用nginx而不是apache

我试图翻译这些规则,我想到了:

location /about { 
  rewrite ^/about\.html$ /index.html?page=about; 
}    
location /archive { 
   rewrite ^/archive\.html$ /index.html?page=archiveindex; 
}
location /sonic1 { 
   rewrite ^/sonic1/index\.html$ /index.html?page=archivegame&game=s1;
}
location /sonic2 { 
   rewrite ^/sonic2/index\.html$ /index.html?page=archivegame&game=s2; 
}
location /sonic3 { 
   rewrite ^/sonic3/index\.html$ /index.html?page=archivegame&game=s3; 
}
由于某些原因,这些规则不起作用

长话短说当有人访问我的网站并写道:

/about
/about.html
我希望将其重定向到此页面
/index.html?page=about

这些规则适用于所有其他规则,如果其中一个规则有效,我将找出如何执行其余规则

任何帮助都将不胜感激

原始apache规则:

RewriteRule ^about\.html$ index.html?page=about
RewriteRule ^archive\.html$ index.html?page=archiveindex
RewriteRule ^sonic1/index\.html$ index.html?page=archivegame&game=s1
RewriteRule ^sonic2/index\.html$ index.html?page=archivegame&game=s2
RewriteRule ^sonic3/index\.html$ index.html?page=archivegame&game=s3
RewriteRule ^sonicandknuckles/index\.html$ index.html?page=archivegame&game=sk

正如我所承诺的,我正在发布我最后为我以前的apache规则(htaccess)而提出的nginx规则


正如我所承诺的,我正在发布我最后为我以前的apache规则(htaccess)而提出的nginx规则


感谢您的编辑并使其可读性。显示原始的.htaccess指令可能会很有用。“
/about
/about.html
”-上述内容将仅重写
/about.html
-但所需的模式可能与.htaccess相同(如果您使用的是mod_rewrite,或者您使用的是mod_alias)?我已添加了可用的原始apache规则。我还有另外两条规则,但我在想,如果我能弄明白这些,我就能做其他的。我已经设法自己做到了。无论如何,谢谢你的努力!请将其添加为一个答案,以便我们都能受益:)感谢您的编辑并使其可读性。也许显示您的原始.htaccess指令会很有用。“
/about
/about.html
”-上述内容将仅重写
/about.html
-但所需的模式可能与.htaccess相同(如果您使用的是mod_rewrite,或者您使用的是mod_alias)?我已添加了可用的原始apache规则。我还有另外两条规则,但我在想,如果我能弄明白这些,我就能做其他的。我已经设法自己做到了。无论如何,谢谢你的努力!请将其添加为答案,以便我们都能受益:)
location = /about {
    rewrite ^/about$ /index.html?page=about permanent;
}

location = /archive {
    rewrite ^/archive$ /index.html?page=archiveindex permanent;
}

location = /sonic1 {
    rewrite ^/sonic1$ /index.html?page=archivegame&game=s1 permanent;
}

location = /sonic2 {
    rewrite ^/sonic2$ /index.html?page=archivegame&game=s2 permanent;
}

location = /sonic3 {
    rewrite ^/sonic3$ /index.html?page=archivegame&game=s3 permanent;
}

location = /sonicandknuckles {
    rewrite ^/sonicandknuckles$ /index.html?page=archivegame&game=sk permanent;
}