Redirect php file to homepage nginx -


i trying redirect old.php ( including parameters) homepage nginx.it should 301 redirect

i tried following rewrite(in server block) not working

rewrite ^old.php(.*)$ https://www.example.com permanent;

i have php location block

location ~* \.php$ {          root /var/www/example.com/public_html/www;         try_files $uri =404;         fastcgi_pass   unix:/run/php5-fpm.sock;         fastcgi_index  index.php;         fastcgi_param  script_filename $document_root$fastcgi_script_name;         include        fastcgi_params; } 

your rewrite directive not working because uri starts /. try replace:

rewrite ^old.php(.*)$ https://www.example.com permanent; 

with:

rewrite ^/old.php(.*)$ https://www.example.com permanent; 

Comments