URL Name and Redirect Help

by 8 replies
9
Hi guys,

I need help from professional web developers regarding an issue which is bothering me for days. Here's the problem:

How can I redirect a URL to an external website by having a link-name of whatever I like within my site?

Please have a look at this site: webhostinggeeks dot com (not mine,hehehe)

In the above website, just click any top ten hosting websites under section "Web Hosting Provider". But before you click, check the URL (on mouseover), that it is pointing within the domain (webhostinggeeks dot com/blahblah.html), but when you click it, it redirects to an external website.

I need to the the same thing for my site.

I need to add this URL: websitename dot com/goto-this-site.html within THIS LINK and when it is clicked, it will redirect to an external website(anotherwebsite dot com).

So how can I do it? Is this a simple redirect or does it involve anything else?

Hope I am making a sense.

Thanks,

Ovais
#programming #redirect #url
  • The mouseover link is correct. However, all that page does it process some stats (e.g. track the click), then redirect to the external URL. You can do this easily with Javascript...

    e.g.
    <script> location.href = "<external URL>"; </script>
    • [1] reply

    • Thanks for the input mate.

      Can you please show me the exact example by applying links on the script you've mentioned

      Link I need to add: mylinkname.html
      The link I need to redirect: externalsite.com

      Thanks,
  • Sure.

    There are several ways to do it. Here's one (the code below is for mylinkname.html)


    HTML Code:
    <!-- 
    ...
    do stuff like record click
    ...
    -->
    
    <script>
    location.href = "http://externalsite.com";
    </script>
    • [1] reply
    • Just to add a bit here (if i am not wrong):

      this code will only work if the browser has JavaScript enabled

      So, what should be done in case of browsers that don't support JavaScript or block JavaScript :confused:

      Another thing, where exactly do we need to put this code
  • Also you can use the HTML below

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Your Page Title</title>
    <meta http-equiv="REFRESH" content="0;url=URL"></HEAD>
    <BODY>
    Optional page text here.
    </BODY>
    </HTML>
  • use 301 redirect. It's good by SEO point of view.
    • [1] reply
    • I recommend using a PHP redirect. Save this code...

      Code:
      <?php
      header('Location: http://www.domaintoredirectto.com/pagetoredirectto.html');
      ?>
      ...as index.php. Just change the URL to the place you want to redirect to. Put the index.php file in an empty directory. For example, if you wanted to redirect to WarriorForum, you could make a directory called warriorforum and put that index.php file in there. If a user went to http://www.yourdomain.com/warriorforum, then that user would be directed to the URL that is specified after the "Location: " part of the index.php file.
  • biztrendz, this is what worked for me. (if you find that it worked for u too kindly give me my first thanks!)

    go to your domain root directory (that is where your wp-content, wp-admin folders are), create a folder with the name that you want it to be linked.

    now go open notepad and paste this inside
    PHP Code:
    <?php
    header
    ('Location: http://www.domaintoredirectto.com/pagetoredirectto.html');
    ?>
    save the file as index.php and drag it into that newly created folder.

Next Topics on Trending Feed