owdan007
asked on
Redirect
I have a website that is being hosted on a LINUX Server. The website has many external links. I want to utilize a single message page that appears when any of the external links are selected. When any external links are selected I want the message page to appear and warn the user that they are leaving the site then redirect them to the original link they selected. Since this is a LINUX Server I was told that it had to be a HTML or PHP script.
Hi,
Something like this can be useful as a simple php script for warning and redirection:
<?php
if(isset($_REQUEST["url"]) )
$url = $_REQUEST['ulr'];
else
die("no url to redirect to");
?>
<strong> Message about you are leaving the website, change accordingly. Will be redirected in a 3 seconds... </strong>
<?php
$redirector = "<meta HTTP-EQUIV=\"refresh\" content=3;url=\"$url\">";
echo $redirector;
?>
To use, pass in something like this (assuming your file is called test.php):
test.php?url=http://www.google.co.nz
Hope this helps.
Something like this can be useful as a simple php script for warning and redirection:
<?php
if(isset($_REQUEST["url"])
$url = $_REQUEST['ulr'];
else
die("no url to redirect to");
?>
<strong> Message about you are leaving the website, change accordingly. Will be redirected in a 3 seconds... </strong>
<?php
$redirector = "<meta HTTP-EQUIV=\"refresh\" content=3;url=\"$url\">";
echo $redirector;
?>
To use, pass in something like this (assuming your file is called test.php):
test.php?url=http://www.google.co.nz
Hope this helps.
ASKER
I tried the example from NIZSMO but, the page comes up and continualy try to redirect but it does not go forward. I don't know what is causing it not to continue to the destination.
I think javascript is by far the easiest method, eg:
<a href="https://www.experts-exchange.com" onClick="alert('Warning - You are accessing an external site ');">Link text</a>
<a href="https://www.experts-exchange.com" onClick="alert('Warning - You are accessing an external site ');">Link text</a>
ASKER
Tintin:
Your example goes to a specifid page. It does not redirect to the unique destination of individual links.
Your example goes to a specifid page. It does not redirect to the unique destination of individual links.
Not sure what you mean. I was going off your original description that said you wanted a warning displayed whenever someone clicked on a link that was external to your site. Is that not what you want?
ASKER
By external link I meant that when a link on my website has a destination outside of my website I want a message page to come up warning them that they are leaving the site and then continue to send them to that link.
ASKER
Just to highlight a key point in my original question:
I want to utilize a single message page that appears when any of the external links are selected. When any external links are selected I want the message page to appear and warn the user that they are leaving the site then redirect them to the original link they selected
I want to utilize a single message page that appears when any of the external links are selected. When any external links are selected I want the message page to appear and warn the user that they are leaving the site then redirect them to the original link they selected
I see now.
My solution will popup a warning message that the use is leaving the site and then continue to the link.
Is it really important to to have a separate message page to appear rather than a popup?
My solution will popup a warning message that the use is leaving the site and then continue to the link.
Is it really important to to have a separate message page to appear rather than a popup?
ASKER
Yes it is. Your script is set to redirect to a specific URL. All links on my site must go to the same message page first then continue to their respective URL's.
owdan007:
sorrry i had a typo in my script, try again here:
<?php
if(isset($_REQUEST["url"]) )
$url = $_REQUEST['ulr'];
else
die("no url to redirect to");
?>
<strong> Message about you are leaving the website, change accordingly. Will be redirected in a 3 seconds... </strong>
<?php
$redirector = "<meta HTTP-EQUIV=\"refresh\" content=3;url=\"$url\">";
echo $redirector;
?>
sorrry i had a typo in my script, try again here:
<?php
if(isset($_REQUEST["url"])
$url = $_REQUEST['ulr'];
else
die("no url to redirect to");
?>
<strong> Message about you are leaving the website, change accordingly. Will be redirected in a 3 seconds... </strong>
<?php
$redirector = "<meta HTTP-EQUIV=\"refresh\" content=3;url=\"$url\">";
echo $redirector;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I still don't get you.
Either method (popup or message page) will still "redirect" to a specific URL. The only difference is the way the message is displayed/defined.
Either method (popup or message page) will still "redirect" to a specific URL. The only difference is the way the message is displayed/defined.
In fact I just tested and it works.
Usage: test.php?url=yourURL
eg: test.php?url=http://www.google.com
Let me know how you get on.
Usage: test.php?url=yourURL
eg: test.php?url=http://www.google.com
Let me know how you get on.
in the <head>
insert this code-
<meta http-equiv="refresh" content="5;url=http://www.newlink.com">
replacing newlink with the external link you desire. The rest of the page is the warning message. This code will tell the browser to display the page for 5 seconds, then go to www.newlink.com