我真的需要帮助。 现在坐了一会儿,不知道该怎么办。
我想要实现一个非常简单的任务 – 重写一个不存在的PHP文件到另一个前所未有的PHP文件,所有参数如:
this http://example.com/nonexistent.php?url=google.com to -> http://example.com/existent.php?url=google.com
我尝试了这样的事情:
rewrite ^/nonexistent.php /existent.php;
哪个不工作(文件未find)。 但redirect一个不存在的HTML文件到这样的PHP文件:
rewrite ^/nonexistent.html /existent.php;
作品。
我不想重写一个html文件,但这仍然是一个令人困惑的行为。
因此,它也尝试了这样的(和一些变化):
rewrite ^/nonexistent.php?url=^(.*)$ /existent.php?url=$1;
这也是行不通的。 (也许语法不好)
任何帮助吗? 这将是非常好的!
location = /nonexistent.php { rewrite ^ /existent.php last; }