The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
5 posters

    Redirect to other address

    avatar
    cupcup
    Forumember


    Posts : 36
    Reputation : 1
    Language : english

    Solved Redirect to other address

    Post by cupcup November 24th 2014, 5:28 am

    Hello someone, i want to ask tutorial
    how to make redirect page on other page?
    example:
    you can't open forum.com/u1 then if you open forum.com/u1 it will be redirect to forum.com/contact
    how to it?
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Redirect to other address

    Post by SLGray November 24th 2014, 5:34 am

    Do you mean when you press the username link you want it to redirect to the contact page?



    Redirect to other address Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    cupcup
    Forumember


    Posts : 36
    Reputation : 1
    Language : english

    Solved Re: Redirect to other address

    Post by cupcup November 24th 2014, 5:36 am

    SLGray wrote:Do you mean when you press the username link you want it to redirect to the contact page?
    yes like it
    and another page too
    like forum 1 redirect to forum 2 and other
    can it?
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Redirect to other address

    Post by _Twisted_Mods_ November 24th 2014, 5:54 am

    goto

    admin control panel>modules>html&javascript managment>javascript

    make sure Enable Javascript code management : yes
    then save


    then create a new javascript

    title: name what you want

    placement: in all pages

    javascript code:

    Code:
    $(function(){
     Â $('a[href="/u1"]').attr('href','/forum');
    });

    /u1 is the url on all the pages you want to change
    /forum is the url it changess it to

    if you want to add more urls to change just add another line

    Code:
     $('a[href="/u1"]').attr('href','/forum');

    so it will be like

    Code:
    $(function(){
    $('a[href="/u1"]').attr('href','/forum');
    $('a[href="/u2"]').attr('href','/forum');
    $('a[href="/u3"]').attr('href','/forum');
    });


    once your all done click submit under the code and your done
    avatar
    cupcup
    Forumember


    Posts : 36
    Reputation : 1
    Language : english

    Solved Re: Redirect to other address

    Post by cupcup November 24th 2014, 6:06 am

    _Twisted_Mods_ wrote:goto

    admin control panel>modules>html&javascript managment>javascript

    make sure Enable Javascript code management : yes
    then save


    then create a new javascript

    title: name what you want

    placement: in all pages

    javascript code:

    Code:
    $(function(){
     Â $('a[href="/u1"]').attr('href','/forum');
    });

    /u1 is the url on all the pages you want to change
    /forum is the url it changess it to

    if you want to add more urls to change just add another line

    Code:
     $('a[href="/u1"]').attr('href','/forum');

    so it will be like

    Code:
    $(function(){
    $('a[href="/u1"]').attr('href','/forum');
    $('a[href="/u2"]').attr('href','/forum');
    $('a[href="/u3"]').attr('href','/forum');
    });


    once your all done click submit under the code and your done
    thank you very much, its work, but if you entered manual on address bar its not redirect, can fix it?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Redirect to other address

    Post by Ange Tuteur November 24th 2014, 7:02 am

    Hello cupcup,

    Try this :
    Administration Panel > Modules > JavaScript codes management > Create a new script

    Title : Your choice
    Placement : In all the pages
    Paste one of the codes below and submit :

    Redirect for all members :
    Code:
    if (/\/u1/.test(window.location.pathname)) window.location.pathname = '/contact';

    Redirect for guests only :
    Code:
    /\/u1/.test(window.location.pathname) && $(function() {
     Â if (_userdata.session_logged_in===1) return;
     Â window.location.pathname = '/contact';
    });
    avatar
    cupcup
    Forumember


    Posts : 36
    Reputation : 1
    Language : english

    Solved Re: Redirect to other address

    Post by cupcup November 24th 2014, 3:10 pm

    hahaha i love u ^^,
    how to remove address using javascript?
    example: forum.com/u1 remove the link from inspect element
    if someone open forum.com/u1 its showing blank page or error
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Redirect to other address

    Post by _Twisted_Mods_ November 24th 2014, 7:33 pm

    this is what i was able to come up with...

    it blacks out the screen and puts a link in the middle of the page redirecting back to the forum

    javascript

    Code:
    $(function() {
      reDir(/\/u\d+/);
     
      function reDir() {
        var args = arguments,i;
        var overlay = jQuery('<div id="overlay"><div class="thetext"><a href="' + window.location.origin + '/forum">Go Back To The Forum</a></div></div>');
        for (i=0; i<args.length; i++) if (args[i].test(window.location)) overlay.appendTo(document.body);
      }
    })();

    this code works on all users profile if you want to set it for only some users

    change


    Code:
        reDir(/\/u\d+/);



    example

    Code:
     reDir(/\/u1/,/\/u2/,/\/u3/);



    you can also edit the url in the middle of the page


    Code:
    <a href="' + window.location.origin + '/forum">Go Back To The Forum</a>



    window.location.origin = your forum url

    everything else leave the same


    your css you will need

    Code:
    #overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: #000;
        z-index: 10000;
     
    }

    .thetext{
        position:relative;
        top:50%; text-align: center
      color:white;
    }

    you can edit

    the background color
    Code:
    background-color: #000;

    and the font color

    Code:
     color:white;
    avatar
    cupcup
    Forumember


    Posts : 36
    Reputation : 1
    Language : english

    Solved Re: Redirect to other address

    Post by cupcup November 26th 2014, 4:23 am

    thank you very much
    Ramdaman
    Ramdaman
    Active Poster


    Male Posts : 1590
    Reputation : 99
    Language : English, Albanian, Macedonian, Russian | HTML, CSS
    Location : New York City

    Solved Re: Redirect to other address

    Post by Ramdaman November 26th 2014, 4:29 am

    Topic solved and archived.

      Current date/time is September 22nd 2024, 2:20 pm