Samuel Tulach Samuel Tulach - 2 months ago 5
Javascript Question

Redirect from URL (PHP or JavaScript)

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!

Answer

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

Comments