PHP PHP Redirects Other than header(location:)

  • Thread starter Thread starter JamesU
  • Start date Start date
  • Tags Tags
    Php
AI Thread Summary
In PHP, the common method for redirection is using the header(location:) function, but alternatives exist. One such method involves using JavaScript to redirect by writing a script that sets window.location to the desired URL. This can be implemented within a PHP function by echoing the JavaScript code. It's noted that using JavaScript for redirection may trigger a warning in some browsers if redirecting to a different server. The discussion emphasizes the importance of providing assistance in help forums, highlighting that users seek solutions rather than vague advice.
JamesU
Gold Member
Messages
821
Reaction score
3
Is there another way to redirect in PHP other than the header(location:) method...? such as one that can be used in a function.
 
Technology news on Phys.org
Download the PHP manual, it has all you need to know.
 
You can use Javascript to redirect using:
Code:
<script>
window.location = '[PLAIN]https://www.physicsforums.com';[/PLAIN] 
</script>
So one alternative is to redirect using PHP to write that on top of a page.
 
Last edited by a moderator:
Big help verty... :rolleyes:


The two listed are the two I use, but I'm not a whiz.
 
Dave, teach a man to fish...
 
verty said:
Dave, teach a man to fish...

This is a help forum. He's come here for help because he didn't find the answer.

With your philosophy, this entire Physics board would be one page: a keyword search of Amazon.com. :-p
 
I'm not that harsh. I knew others would answer. I think in some browsers a window might pop up saying "the page is trying to redirect" if your redirect is to a different server.
 

Similar threads

Replies
13
Views
2K
Replies
7
Views
7K
Replies
12
Views
2K
Replies
5
Views
3K
Replies
32
Views
2K
Replies
3
Views
1K
Replies
2
Views
5K
Replies
4
Views
6K
Back
Top