PHP Redirects Other than header(location:)

  • PHP
  • Thread starter JamesU
  • Start date
  • Tags
    Php
In summary, there are multiple ways to redirect in PHP, such as using the header(location:) method or using Javascript. The PHP manual is a helpful resource for learning about these methods. Additionally, it is possible to redirect using PHP at the top of a page. However, it is important to also provide assistance and guidance to others seeking help, rather than solely directing them to external resources.
  • #1
JamesU
Gold Member
821
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
  • #2
Download the PHP manual, it has all you need to know.
 
  • #3
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:
  • #4
Big help verty... :rolleyes:


The two listed are the two I use, but I'm not a whiz.
 
  • #5
Dave, teach a man to fish...
 
  • #6
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
 
  • #7
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.
 

FAQ: PHP Redirects Other than header(location:)

What is a PHP redirect?

A PHP redirect is a technique used to redirect a user from one webpage to another. It is commonly used in web development to redirect users to a different page after a form submission or to redirect them to a new URL.

How does a PHP redirect work?

A PHP redirect works by using the header() function to send a special HTTP header to the browser, instructing it to redirect to a new page. This is typically done by setting the "Location" header to the URL of the desired page.

Why use a PHP redirect instead of HTML redirects?

PHP redirects are more powerful and flexible than HTML redirects. They allow for dynamic redirection based on conditions, such as user input or session information. Additionally, PHP redirects can be used to redirect to external URLs, whereas HTML redirects are limited to pages within the same website.

Is it possible to perform a PHP redirect without using header(location:)?

Yes, there are other ways to perform a PHP redirect without using the header() function. One alternative is to use the meta refresh tag in HTML. However, this method is not recommended as it is less efficient and can cause issues with browser caching.

Are there any security concerns with using PHP redirects?

There are potential security concerns with using PHP redirects, as they can be vulnerable to attacks such as cross-site scripting (XSS) and open redirects. To mitigate these risks, it is important to properly validate and sanitize all user input before using it in a redirect and to use HTTPS for all redirects to external pages.

Similar threads

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