The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Redirect to other address

View previous topic View next topic Go down

Solved Redirect to other address

Post by cupcup on 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?

cupcup
Forumember

Posts : 36
Reputation : 1
Language : english

Back to top Go down

Solved Re: Redirect to other address

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

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


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


SLGray
Administrator
Administrator

Male Posts : 35672
Reputation : 2375
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

Solved Re: Redirect to other address

Post by cupcup on 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?

cupcup
Forumember

Posts : 36
Reputation : 1
Language : english

Back to top Go down

Solved Re: Redirect to other address

Post by _Twisted_Mods_ on 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

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Redirect to other address

Post by cupcup on 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?

cupcup
Forumember

Posts : 36
Reputation : 1
Language : english

Back to top Go down

Solved Re: Redirect to other address

Post by Ange Tuteur on 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';
});

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Redirect to other address

Post by cupcup on 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

cupcup
Forumember

Posts : 36
Reputation : 1
Language : english

Back to top Go down

Solved Re: Redirect to other address

Post by _Twisted_Mods_ on 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;

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Redirect to other address

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

thank you very much

cupcup
Forumember

Posts : 36
Reputation : 1
Language : english

Back to top Go down

Solved Re: Redirect to other address

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

Topic solved and archived.

Ramdaman
Active Poster

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

http://ndihme.forumotion.com/forum

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum