0

I don't have so much knowledge of programming, so I want some help. I want to redirect 301 a url /viewforum.php?f=19 to another page. So want to put in viewform.php to do so. I using the following code

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");
exit();
?>

But it redirecting everything within /viewform.php but I only want to redirect /viewform.php?f=19

  • 1
    You can also redirect from [htaccess](https://httpd.apache.org/docs/current/howto/htaccess.html). – Ganesh Patil Jun 24 '16 at 06:55
  • As mentioned above by Ganesh, you can redirect from `.htaccess` as well, which I would recommend that you do, that way you'll have a easier overview of your redirects and won't have to remember where you placed different redirects in different files. – Epodax Jun 24 '16 at 06:56
  • I hope This reference link help to you http://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php Thank You!! – Ragu Natarajan Jun 24 '16 at 07:04

1 Answers1

1
<?php
        if($_GET['f']==19)
        {    
            //header("HTTP/1.1 301 Moved Permanently"); no need
            header("Location: http://www.example.com/");
            exit();
        }
?>

Hope it will help

Naisa purushotham
  • 905
  • 10
  • 18