AvacWeb
  • HomeHome  
  • SearchSearch  

    Search Query


    Display results as :


    Advanced Search Advanced Search

  • MemberlistMemberlist  
  • RegisterRegister  
  • AWC  
  • Log inLog in  

Topics

    Users

      Posts

        NEW AWC 2.1 UPDATE IS HERE | Get it here!
        (150px x 30px Banner)
        #tutorial #LGBB #tips #OST #AWC
        Trending Hashtags

        The most tagged members


        Page 1 of 1 • 

        Replace an URL with URL that equals to it

        avatarHitsu
        Hitsu
        Status : Finished on working fmAPI.

        Posts : 280
        Join date : 2013-09-09
        Age : 19
        Location : Indonesia
        Post #23250
        on Mon 01 Jun 2015, 01:54
        So, I would like to know how to replace an URL with another URL that equals to it.
        Example like this:

        Code:
        var links = {
        insane:'crazy',
        test:'testing'
        };

        So the script would replace the URL. Like, if we typed [ic]urltotheforum.forumotion.com/insane[/ic] then the script would replace the URL into [ic]urltotheforum.forumotion.com/crazy[/ic].

        Thank yu.
        Thank Poster
        avatarBloodbath
        Bloodbath
        Status : No status yet...

        Posts : 745
        Join date : 2013-05-31
        Age : 22
        Post #23251
        on Mon 01 Jun 2015, 11:07
        It's not possible to do URL rewriting (like you can on an Apache server using .htaccess). There are ways to load a new page through JavaScript, but you can't link to an invalid page or the JS won't work.
        Thank Poster
        avatarHitsu
        Hitsu
        Status : Finished on working fmAPI.

        Posts : 280
        Join date : 2013-09-09
        Age : 19
        Location : Indonesia
        Post #23252
        on Mon 01 Jun 2015, 13:11
        So is there another way to write it? ANY other way.
        Thank Poster
        avatarBloodbath
        Bloodbath
        Status : No status yet...

        Posts : 745
        Join date : 2013-05-31
        Age : 22
        Post #23253
        on Mon 01 Jun 2015, 13:44
        Basically, if you want, for example, "/t41235-" to redirect to "/t1234-", then yes, that's possible, but I am afraid that what you have in mind isn't.
        Thank Poster
        avatarHitsu
        Hitsu
        Status : Finished on working fmAPI.

        Posts : 280
        Join date : 2013-09-09
        Age : 19
        Location : Indonesia
        Post #23254
        on Mon 01 Jun 2015, 21:09
        Oh, yes, that's what I need. Could you give me some instruction? Thank you very much. Very Happy
        Thank Poster
        avatarDom
        Dom
        Status : No status yet...

        Posts : 515
        Join date : 2011-12-24
        Location : USA
        Post #23255
        on Mon 01 Jun 2015, 21:30
        Sure, you can definitely do that. But it has to be a real URL already on the forum.

        Code:
        var redirects = {
        "t1234": "t2314-",
        "t123": "t1-"
        };

        for (var to in redirects) {
            if (window.location.pathname.indexOf(to) === 1) window.location.pathname = redirects[to];
        }

        It should work. I haven't worked with JavaScript for some time, but it should be right.
        Thank Poster
        avatarHitsu
        Hitsu
        Status : Finished on working fmAPI.

        Posts : 280
        Join date : 2013-09-09
        Age : 19
        Location : Indonesia
        Post #23257
        on Tue 02 Jun 2015, 13:12
        Right, thank you! I'll test it in a minute.
        Thank Poster
        avatarLGforum
        LGforum
        Status : Restoring Avacweb...

        Posts : 2873
        Join date : 2011-10-05
        Age : 24
        Location : UK
        Post #23276
        on Tue 09 Jun 2015, 15:25
        You can put change the URL of an address without server side re-writing but you can change where a link on the page sends you:
        (Ugly JQuery example to show what I mean)
        Code:
        [panda=js]$('a[href="/crazy").click(function(e){ e.preventDefault(); window.location = 'new location' });

        If this is okay for you I can write something more complete.
        Thank Poster
        avatarHitsu
        Hitsu
        Status : Finished on working fmAPI.

        Posts : 280
        Join date : 2013-09-09
        Age : 19
        Location : Indonesia
        Post #23309
        on Sun 14 Jun 2015, 23:24
        Ah, right. I've forgotten that I can write something easy like that lol, JK. But of course, it just might work if the link was clicked, ex like an URL bbcode. So, if that's not a problem for you: can you write more complete code? Thank you so much. ^^
        Thank Poster
        Sponsored contentSponsored content
        Post #0
        Thank Poster

        Previous Topic • Next Topic

        Copyright © Avacweb 2011 -

        Free forums hosting | © phpBB | Free forum support | Contact | Report an abuse | Free forum