Announcement

Collapse
No announcement yet.

How to change external links to internal links to do something before redirecting to the destination

Collapse
This is a sticky topic.
X
X
Collapse
First Prev Next Last
  • Filter
  • Time
  • Show
Clear All
new posts

    [Official - Free] How to change external links to internal links to do something before redirecting to the destination

    There are cases when you want external links posted in your forum to go through your page first before redirecting to the external URL. Most sites do this. Here are the reasons why you would want to do this:

    1. To track the clicks to the external links.
    2. To display an interstitial page to inform/warn user that they are navigating away from your site.

    Click image for larger version  Name:	redirect-min.png Views:	1 Size:	14.3 KB ID:	1943

    See how Yelp does #2.
    Without further ado, here's how to do it.

    There are 2 parts to do this:
    • Creating the redirect page. This is only for #2 above. For #1, you're on your own. If you already have set it up, you can skip this)
    • Editing the php file to change the external links to point to the redirect page.

    Create the Redirect Page:

    1. Create a new page in Sitebuilder.
    2. Drag and drop a PHP module.
    Title: Redirecting... (or whatever you want)
    PHP Code: (Change 5000 milliseconds to whatever delay you want)
    PHP Code:
    You need to be logged in to view the code. Login or Register now!

    3. Save the page and fill out the page information.
    Save the page name: Redirecting... (or whatever you want to show up in the tab name)
    Save the page URL based on the page name: redirect (this is what you're going to use when editing the PHP file)
    Template option: Redirect Template


    Edit the PHP File:

    1. Logon to cPanel (or equivalent).
    2. Edit the following PHP file:
    Code:
    You need to be logged in to view the code. Login or Register now!
    3. Change these:
    PHP Code:
    You need to be logged in to view the code. Login or Register now!

    with these: (change $redirect_path with the appropriate path of the redirect URL)
    PHP Code:
    You need to be logged in to view the code. Login or Register now!

    4. Clear system cache in AdminCP > Maintenance > Clear System Cache.


    Screenshot:

    Click image for larger version  Name:	redirect-page-min.png Views:	1 Size:	25.0 KB ID:	1963

    NOTE: Since this is a PHP hack, this change will be overwritten during upgrade. So you have to re-apply this change whenever you upgrade.
    Last edited by glennrocksvb; 05-07-2018, 04:53 PM.

    #2
    Hello,
    1: i try do that change this ( what i have in my
    /includes/vb5/template/bbcode.php )
    HTML Code:
    You need to be logged in to view the code. Login or Register now!
    with these:

    HTML Code:
    You need to be logged in to view the code. Login or Register now!
    Clear system cache ... after that my site not working !
    2: can you please more clarification about this (change $redirect_path with the appropriate path of the redirect URL)
    Thank You

    Comment


      #3
      for example this my goodbye page
      http://shneler.com/test/22.html
      were should add in second HTML Code:?

      Comment


        #4
        Could you elaborate on "my site not working"? What does not work? Saying "not working" does not help.

        Btw, there is a bug in vB where the backslash character "\" in the post goes away after posting or editing. I had to double the backslash to be able to show one. Make sure you copied the code in the first post correctly with backslashes preserved.

        Comment


        • William
          William commented
          Editing a comment
          I think he is referring to the instructions: with these: (change $redirect_path with the appropriate path of the redirect URL)

          Would this be correct in his case: $redirect_path = "/test/22.html";

          ???

        #5
        attached my original bbcode.php
        change to me and add redirect page http://shneler.com/test/22.html
        i will test and back to you quickly
        Attached Files
        You need to be logged in to download the files. Login or Register now!

        Comment


        • glennrocksvb
          glennrocksvb commented
          Editing a comment
          See post #7

        #6
        http://shneler.com/vb/
        Last edited by moded; 11-15-2016, 02:46 PM.

        Comment


        • glennrocksvb
          glennrocksvb commented
          Editing a comment
          What is this URL for?

        #7
        You need to be logged in to view the quote. Login or Register now!
        That's correct. But I wonder what's in that 22.html file. It should have the code to redirect to the external URL passed in the querystring.

        Comment


          #8
          You need to be logged in to view the quote. Login or Register now!
          FYI. I posted a bug report for this in http://tracker.vbulletin.com/browse/VBV-16703

          Comment


            #9
            why when i follow the above steps i see blank page ...and were is the html code should add in redirect page ?

            Comment


              #10
              You need to be logged in to view the quote. Login or Register now!
              Yes i can't editing the post , when i do that my forum frozen

              Comment


                #11
                You need to be logged in to view the quote. Login or Register now!
                When do you see the blank page? After clicking the link that should redirect to the external link? Or when loading the thread page itself? Please be more specific.

                Btw, this thread does not include the implementation of the redirect page itself. This is up to you. As I mentioned in the first, there are 2 possible ways to implement this. And the second way is how Yelp does it as shown in the screenshot I attached. But this thread does not show how to implement any of those ways. What this thread shows is how to change the external links in the posts to internal links in order for you to implement any of those 2 ways.

                Comment


                • William
                  William commented
                  Editing a comment
                  Would be nice to include if possible a how to create an article page using Vb 5 and making that a redirect page. Not trying to create more work for you Glenn, but it just makes sense to me. That is, if it is possible to use the cms.

                • glennrocksvb
                  glennrocksvb commented
                  Editing a comment
                  You have a point. You can create a new page in vB5 and then include an HTML module to display a message and add a script to redirect to the external URL after a certain delay or after clicking a button or link. I will post detailed instructions on that when I get a chance.

                #12
                I have edited the first post to add instructions on how to create the redirect page.

                Comment


                • William
                  William commented
                  Editing a comment
                  Do you still need to do this: with these: (change $redirect_path with the appropriate path of the redirect URL)

                  If we are using the vb cms as the redirect page? What would the url be if I did this mod for my site? I read this and about to give a try, I just wanted to be crystal clear beforehand: Save the page URL based on the page name: redirect (this is what you're going to use when editing the PHP file)
                  Last edited by William; 11-15-2016, 11:38 PM.

                #13
                I feel like an idiot, I didn't realize there were multiple places to change the code!!!!

                You said: with these: (change $redirect_path with the appropriate path of the redirect URL)


                Enjoy,
                William
                Last edited by William; 11-16-2016, 12:33 AM.
                Christian Forums

                Comment


                • glennrocksvb
                  glennrocksvb commented
                  Editing a comment
                  Glad you figured it out.
                  And thanks for the cream and sugar

                #14
                Thank you Glenn and William it is working perfect
                here test
                can you add to above PHP module , redirect the user when he ask to download attached file , already upload in forum root ?

                Last edited by moded; 11-16-2016, 08:46 AM.

                Comment


                  #15
                  What's the best way to track someone clicking what link and resulting redirect page? I am watching Google Analytics "live" and seeing people being redirected to the page. This is a wonderful addition if it can be tracked from an admin's point of view. So often it seems that someone is just replying to a title rather than the article in a discussion. It would be quite nice to be able to verify this .... . as it would save me much breath in ignoring such users that I see ignoring the article.

                  Also is it possible to have a "proceed offsite" and "go back to thread" buttons in case someone doesn't want to be redirected out of the site?

                  Enjoy,
                  William
                  Last edited by William; 11-16-2016, 01:25 PM.
                  Christian Forums

                  Comment


                  • glennrocksvb
                    glennrocksvb commented
                    Editing a comment
                    What kind of tracking do you want? Track who clicks what link and when? And then count the clicks per link?
                Working...
                X