I want to set a rewrite rule for redirection of search.php?q=word to word.domain.com I used the following rule but did not work. rewrite ^(.*).$server_name /search.php?q=$1 permanent; Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220917,220917#msg-220917