Redirecting to a url in PHP


I would like to redirect from a page to another. I tried to use the html tag
but it does not work.

Is there a way to do a redirect in PHP?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


You can redirect with php using the header() function.

Your code should look as this:
header("Location:");  /* Redirect browser to PHP web site */
exit;  /* Make sure that code below does not get executed when we redirect. */


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Easy in PHP

stephaneeybertAuthor Commented:
Thanks guys. Who wants the points?
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

I think my comment answers your question
<META HTTP-EQUIV='REFRESH' CONTENT='3; URL=newpage.html'> ... :))

Be careful, before the header function, you musn't stdout something otherwise it won't work.
stephaneeybertAuthor Commented:
Thanks for all your comments.

The only thing new that I got from you guys, is from "chkassen", who tipped me first about the function "header()". Unfortunately, I cannot use this function in my application, because I want to output some warning message for a few seconds before doing the redirection.

The html tag I was using didn't work, because there was a <style> tag and a <div> tag on the same page for a layer. It seems that when there is a layer on a page, the <meta http-equiv> tag cannot be used. One more html bug?

So I removed my layer, and now I can do the redirection using my <meta http-equiv> tag.

But anyway here are the points.

stephaneeybertAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.