简单的NGinx重写就是redirect

我试图为我的Nginx服务器上运行的网站设置一个友好的URL,但由于某种原因,url正在被redirect,而不是被重写

例如,如果用户访问mydomain.com/aboutme/我想mydomain.com/aboutme/留在地址栏中,但要从mydomain.com/aboutme.php

在我的Nginx站点configuration中,我有以下几个(简单的例子,为了简单起见,一些东西被砍掉):

server { listen 1.2.3.4:80; server_name www.mydomain.com; location / { rewrite ^/aboutus/$ http://www.mydomain.com/aboutus.php permanent; } } 

不pipe出于什么原因,Nginx似乎坚持将友好的urlredirect到php文件,但是我想要一个更传统的“重写”(就像我之前在Apache mod_rewrite中所做的一样)。

我可能做错了什么,但是如果我能弄清楚什么的话,我会被诅咒的。

你得到一个301redirect,因为你特别要求301redirect 。

要解决这个问题,请使用相对的目标url,而不是permanent

例如:

 rewrite ^/aboutus/$ /aboutus.php last;