0

Hi everyone, happy new year!!!

I am trying to add some extra "security" to my website. I would like all links that do not link to my website to visit an "out" page that will tell the user that they are being taken to an external domain.

Would I be able to do this with PHP alone or will I need to use some JavaScript as well?

Many thanks.

3
Contributors
8
Replies
11
Views
5 Years
Discussion Span
Last Post by hakeemtunde
0

I assume you'd want to use a confirm dialog for this, so you'd need JS, not PHP.
I don't know what you mean by 'security' though.

If your external site links have soemthing like class="ext" in them you could use js to handle the clicks:

e.g.
using jquery

$('a.ext').click(function(){
  var ask = confirm("This link will take you to an external site. Do you wish to proceed?")
  if (ask){
     window.location = $(this).attr('href');
  }
});

Not tested

0

I would rather not do it that way. As a lot of the links are from people who post things on my website and I don't want to manually add the

class="ext"

to each link. I would also like it to detect external links and take them to a page like "out.php?url=http://www.google.com"

0

Same to YOu.

i dont understand what you mean. When you talk of links it my be a link behind a button or <a> tag or you mean all the links on your site shouldn't go to external web page may be through redirection, actually i understand can give an example.

0

Same to YOu.

i dont understand what you mean. When you talk of links it my be a link behind a button or <a> tag or you mean all the links on your site shouldn't go to external web page may be through redirection, actually i understand can give an example.

0

Ok sorry,

On my website I have a page where people can post content and some of them post URLs. Quite a lot of the time the URLs that they post take people to external domains. For example someone might post a link to a facebook page.

When the link is posted it would be like a normal link.

<a href="http://www.facebook.com/pagename">http://www.facebook.com/pagename</a>

I would like it so that when someone posts a link to a page that is not on my website the link would be like the following.

<a href="http://www.mydomain.com/external.php?redirect=http://www.facebook.com/pagename">http://www.facebook.com/pagename</a>

If someone posted a link to a page that is on my website then it should be displayed like a normal link

<a href="http://www.mydomain.com/attachment.php?id=1234">http://www.mydomain.com/attachment.php?id=1234</a>
0

Ok, thanks!

Sometimes users post content that may not be suitable or could cause harm to the users computer so I just want to make a page that warns the user that they are being taken to page that isn't on my website.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.