I am trying to redirect www.xyz.com/my
to www.abc.com
, how can I do this in PHP?
Strictly speaking you need to send a HTTP location header to the clients browser.
To do this in PHP, as the other answers have mentioned is to use the header()
function.
header("Location: http://www.abc.com");
There is a caveat that you should be aware of. The most common problem people encounter when dealing with HTTP headers is that they must be sent to the browser prior to any other data. If you echo any content to the client and then try to send the location header, it wont work.
For reference, there are many other HTTP headers that you should familiarize your self with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With