Nginx Rewrite Rule To 301 redirect filename.asp to filename.php

view story

http://serverfault.com – I have changed my file names from filename.asp to filename.php but now I want to 301 redirect all the requests coming to filename.asp to its equivalent filename.php I have tried these variations but they only redirect to the homepage: if ($request_uri ~ ..asp.) { rewrite ^ http://$host? permanent; #rewrite ^/(.*)$ /$1.php permanent; } domain.com/folder/filename.asp 301 redirect to domain.com/folder/filename.php Thanks (HowTos)