how to detect a redirected url |
how to detect a redirected url |
The_webmaster |
Feb 8 2021, 05:02 AM
Post
#1
|
Member Group: Members Posts: 40 Joined: 5-February 21 Member No.: 27,773 |
Please guys i want a code which i can use to detect the url that redirected to my webpage. Both php and javascript is accepted
This post has been edited by The_webmaster: Feb 8 2021, 05:04 AM |
Christian J |
Feb 8 2021, 08:44 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
Do you mean the URL of any other website? Then you can detect the "referer" HTTP header with either javascript or PHP. It's possible for users to change it though, so don't rely on it for security.
Or do you mean one of your own pages redirecting to another? |
The_webmaster |
Feb 8 2021, 10:57 AM
Post
#3
|
Member Group: Members Posts: 40 Joined: 5-February 21 Member No.: 27,773 |
Do you mean the URL of any other website? Then you can detect the "referer" HTTP header with either javascript or PHP. It's possible for users to change it though, so don't rely on it for security. Or do you mean one of your own pages redirecting to another? Yes url from another website |
pandy |
Feb 8 2021, 11:45 AM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,732 Joined: 9-August 06 Member No.: 6 |
So you mean a simple link to your site from some other site?
In addition to what Christian said the referer header should be in your access logs and a statistics software that read the logs will display the URLs of referring pages. |
Christian J |
Feb 8 2021, 12:07 PM
Post
#5
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
With PHP you can use
CODE echo $_SERVER['HTTP_REFERER']; See also https://www.php.net/manual/en/reserved.variables.server.php Note that there will not always be a referer value, e.g. if the user followed a bookmark or typed the URL in the browser's address bar. |
The_webmaster |
Feb 8 2021, 12:31 PM
Post
#6
|
Member Group: Members Posts: 40 Joined: 5-February 21 Member No.: 27,773 |
With PHP you can use CODE echo $_SERVER['HTTP_REFERER']; See also https://www.php.net/manual/en/reserved.variables.server.php Note that there will not always be a referer value, e.g. if the user followed a bookmark or typed the URL in the browser's address bar. Thank you very much |
pandy |
Feb 8 2021, 01:20 PM
Post
#7
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,732 Joined: 9-August 06 Member No.: 6 |
|
The_webmaster |
Feb 8 2021, 02:08 PM
Post
#8
|
Member Group: Members Posts: 40 Joined: 5-February 21 Member No.: 27,773 |
Thanks for your reply, i just converted the php code to javascript and it worked perfectly.
|
Lo-Fi Version | Time is now: 26th April 2024 - 07:57 PM |