How To Redirect Web Pages To Another Page with PHP or Javascript? – POFTUT

How To Redirect Web Pages To Another Page with PHP or Javascript?

PHP is popular programming or scripting language used to develop web pages. One of the problem developers face is using PHP to redirect user browser to the new page. for example we have an old URL but we want to make transition to the new URL we can achieve this simply by using  PHP redirect.

Simply Redirect

We will use header function of PHP to provide new URL to the client browser. Keep in mind that after using header function there should be no other operation that will output something or simple be sure header is last function.

In this example we will redirect current page to the .

Please notice that we have used exit() function .This will make our page resource usage more effective.

Alternatively Use JavaScript

JavaScript is mainly client side scripting language. Redirect operation can be done with JavaScript on the client side by providing new URL to the windows objects location property like below.

Even we can make a Javascript function to use it multiple times easily

LEARN MORE  Wget Command Tutorial With Examples For Linux and Windows

5 Responses

  1. piala dunia says:

    Hello, Neat post. There is an issue together with your site in web explorer, would check this?
    IE still is the market chief and a large section of people will miss your
    excellent writing due to this problem.

  2. У Вас есть вопросы о работе игрового клуба Вулкан?

  3. I’m not sure exactly why but this blog is loading incredibly slow for me.
    Is anyone else having this issue or is it a issue on my end?
    I’ll check back later and see if the problem still

  4. Damien says:

    It’s an awesome piece of writing for all the online people;
    they will take benefit from it I am sure.

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)