Jump to content

Recommended Posts

I have the following in my index.php page

<?php $url='http://www.external site.co.za';?>

 

in the html side

<a href="#B"><div name="B" href="'.$URL.'"  class="fancybox"></a>

 

The link does not open and says that it cant find the page . Is it becuase it is an external page.

The whole idea is not to display the external sites name.

 

the way it works correctly: but this shows the external file address

<a href="#B"><div name="B" href="http://www.external site.co.za"  class="fancybox"></a>

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/
Share on other sites

div tags do not have an href attribute. Perhaps you mean <iframe> ?

 

Using an iframe would show the site without it's URL being visible in the URL bar, but it would still be visible in the source of the page, so it's not really hidden.

this is in my index.php

 
in the same page on my navigation the html side i have
<script type="text/javascript">
    $(document).ready(function() {
             $(".fancybox" ).fancybox({
            'width'             : '45%',
            'height'            : 550,
            'autoSize'         : true,
            'autoDimensions' : false,
            'fitToView'          : false,
            'titlePosition' : 'inside',
            'transitionIn'      : 'none',
            'scrolling' : 'auto',
            'transitionOut'     : 'none',
            'href'              : $(this).attr('href'),
            'type'              : 'iframe'
});
});
</script>
    <script type="text/javascript">
document.getElementById("container").style.display = "none";  
</script>   
 

<nav>

<a href="#A">
<div id="container" name="A" href="'.$url.'" class="fancybox">
Click</div></a></li>
</nav>
 
 
the button om nav does not find the url specified

ok . what if I do this 

the user then sees selections as the page that he selected and not the actual http://xternalsite.co.za"

 

this is in my index.php

and the html

<nav>

<a href="#Selections">
<div id="container" name="Selections" href="'.$url.'" class="fancybox">
Selections</div></a></li>
</nav>

i manged to do this but it still not what i wanted.

 

in my index.php i got the following

<?php
 
if (isset($_GET['run'])) $linkchoice=$_GET['run'];
else $linkchoice='';
 
switch($linkchoice){
 
case 'first' :
    header("Location: http://www.the other site");
 
    break;
 
case 'second' :
    header("Location: /index.php") ;
    break;
 
}
?>
in html
<p class="submit">
     
<a href="?run=first" class="fancybox" style="position: absolute; left:221px; top:129px">
        <p><input type="submit" value="Selections"></p></a></p>
 

this works fine unless user types in http://www.mysite.php?run=first

it opens the other but site not in my iframe.

You can set up spoof links that show a href attribute of something else and then use header("Location: /new_address.php"), but as user, I'd be highly displeased if a site would try to link me somewhere else than it specified...

 

Example below.

 

<!-- yoursite.php -->
<a href="redirect.php">Click to redirect</a>
<!-- end of yoursite.php -->
<?php // redirect.php
if(isser($_SERVER['HTTP_REFERER']) && preg_match(~yoursite\.php~i,$_SERVER['HTTP_REFERER'])){
header("Location: newsite.php");
} else {
header("Location: othersite.php");
}
// end of redirect.php
?>

ok tks . is this how I should do it. please check if(isset) if correct cos this opens nothing

 

in my redirect.php

<?php // redirect.php
if(isset($_SERVER['HTTP_REFERER']) && preg_match(http//www.mysite.co.za\.php~i,$_SERVER['HTTP_REFERER'])){
header("Location: http://www.site1.co.za");
} else {
header("Location: http//www.mysite.co.za");
}
// end of redirect.php
?>

 

thanks

Your Regular Expression is a bit off...

 

preg_ functions take for each Regular Expression a string which starts with one sign and ends with the same sign, optionally followed by g, i or m (or a combination of those).

I noticed that I myself didn't put them in strings, but since I was on my phone, I did not feel like editing it.

 

Anyway.

 

preg_match("~yoursite.co.za/filename.php~i",$_SERVER['HTTP_REFERER']) should do the trick.

this is waht i have and i get a blank fancybox 

 

<?php // site.php
if(isset($_SERVER['HTTP_REFERER']) && preg_match("~http://www.horsespeedracing.co.za/index.php~i",$_SERVER['HTTP_REFERER'])){
header("Location: http://www.gallop.co.za");
} else {
header("Location: http//www.horsespeedracing.co.za");
}
// end of redirect.php
?>
 
in my testing.php i have
 
      <p class="submit">
     
<a href="site.php" class="fancybox" style="position: absolute; left:221px; top:129px">
        <p><input type="submit" value="VIDOE"></p></a></p>
 
 
 
this is my example i have to test that works. but the user can still go direct if they type new_page-3.php?run=first 
 
Try http:www//horsespeedracing.co.za/php_login_v2.3/phplogin_v2.3/new_page_3.php

That's the one thing you cannot hide unless you'd create your own browser and distribute it to every single internet user.

Sadly, you are not a multi-billion company like Google to afford that (I guess, I highly doubt it), so the answer to that is no.

There is no way to prevent the user from getting the link from SOMEWHERE out of your code, be it now the href attribute or some JavaScript-implemented redirect, the user would be able to figure it out.

You could, if you are very eager for the user not to know where to redirect, try JavaScript code obsfuscation, but that's a pretty shameful thing to do unless you are actually trying to hide crucial data (and even then, you'd be doing it wrong - storing data with JavaScript is generally a bad idea and easily discovered).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.