Avatar of owdan007
owdan007Flag for United States of America 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.
NetworkingLinux OS Dev

Avatar of undefined
Last Comment
Joe Wu

8/22/2022 - Mon
carl_legere

program one simple warning page per external link, externallink1.html for example
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
Joe Wu

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.
ASKER
owdan007

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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Tintin

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>
ASKER
owdan007

Tintin:

Your example goes to a specifid page.  It does not redirect to the unique destination of individual links.
Tintin

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?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
owdan007

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
owdan007

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
Tintin

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?

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
owdan007

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.
Joe Wu

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;
?>
ASKER CERTIFIED SOLUTION
Joe Wu

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Tintin

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Joe Wu

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.