-2

Is it realistic to do when I write www.mysite.com/redirect.php?index.html URL to be redirected to index.html? I need use PHP and HTML or javascript. Thanks in advance for your answer.

How to make a redirect in PHP? - helped! Thanks to all!

Community
  • 1
  • 1
Samuel Tulach
  • 1,319
  • 13
  • 38

3 Answers3

0

Obviusly no.I try to help you when you use this www.mysite.com/redirect.php in this PHP you put this code:

<?php 
    header('Location: http://www.example.com/');
?>

When you make a get petition to this file, it redirect to other URL.

Pedro
  • 36
  • 3
0
<?php  
header('Location: http://www.example.com/');
exit;

You could use header()-function in php to realize a redirect. Make sure there is no output before.

Caz
  • 25
  • 6
0

if you really need do that, could be done better using .htaccess if you are using apache, if you using any other server like ngnix or light-http. https://httpd.apache.org/docs/2.4/rewrite/remapping.html If your are try to do that only with PHP or JS, i'll prefer to do in PHP, becose it'll be more quecly and not need to spent time in load javascript into browser. in PHP will be:

if($_SERVER['REQUEST_URI']==='redirect.php?index.html') header('location:/index.html);

sorry if request uri var is other in your server envoirement.

expect will help

Álvaro Touzón
  • 1,247
  • 1
  • 8
  • 21