nginx: rewrite a non-existent php-file to another php-file with all arguments
Posted
by
at0m33
on Server Fault
See other posts from Server Fault
or by at0m33
Published on 2012-11-27T11:50:24Z
Indexed on
2012/11/28
5:07 UTC
Read the original article
Hit count: 546
i really need help here. Sitting for some time now and dont figured it out.
I want to realize a very simple task - rewrite a non-existent php file to another existant php file with all arguments like:
this http://example.com/nonexistent.php?url=google.com
to -> http://example.com/existent.php?url=google.com
I tried something like this:
rewrite ^/nonexistent.php /existent.php;
Which dont works (File not found). But redirect a non-existent html file to a php file like this:
rewrite ^/nonexistent.html /existent.php;
works.
I dont want to rewrite a html file, but this is still a confusing behaviour.
Therefore it tried also something like this (and some variations):
rewrite ^/nonexistent.php?url=^(.*)$ /existent.php?url=$1;
which is also not working. (Maybe the syntax is bad)
Any help here? It would be very nice!
© Server Fault or respective owner