Skip to:
Content
Pages
Categories
Search
Top
Bottom

trick to make relative URLs instead of full URI


  • _ck_
    Participant

    @_ck_

    It was really bothering me how a page full of links was wasting so many bytes on full absolute URI’s with the domain name, etc. when all it needed was a tidy relative URL. The front page alone is 4k bigger just because of all the full URIs on the tag cloud and views, etc.

    ie. http://www.bbpress.org/forums/forum/plugins

    vs. /forums/forum/plugins

    (multiply that by a few hundred)

    So it dawned on me just now that it’s fairly easy using filters to make all the urls relative. Just for safety, we don’t kick in the relative URLs until bbPress has gotten past the header section of the template. This makes sure that redirects, stylesheets, and javascript is handled properly.

    function bb_relative_uri($r) {return "/forums/"; }	// change forums to your path
    function bb_relative_domain($r) {return ""; }
    function bb_relative() {
    add_filter( 'bb_get_option_domain','bb_relative_domain',255);
    add_filter( 'bb_get_option_uri','bb_relative_uri',255);
    } add_action('bb_head', 'bb_relative',255);

    .

    In some cases, relative URLs actually makes Internet Explorer cache better so this may be helpful for subtle speedups too.

    I haven’t discovered anything broken by this yet but be sure to let me know if you run into anything.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Can I install bbpress on a subdomain? Is this possible?

    Please contact me to cordoval@gmail.com

    Encouragements,


    _ck_
    Participant

    @_ck_

    This topic has nothing to do with subdomains, but you can definitely install bbpress on a subdomain. Just enter the appropriate info during setup.

    Have you installed it on a subdomain yourself?

    I examined the parsing functions and the uri how it is stored in the database. However, I was reluctant that it would not work, I tried but did not work, but partly was because I was changing domain settings on a website.

    Also regarding the uri modifications that I really meant to convey was that I needed to change the uri for a forum that I was moving on my site. I ended up ultimately finding out how to do this. It is actually in the database itself and under user_metatopics or something similar, you just export your database and do a search for uri in the file and you will see what I mean.

    Encouragements, maybe I can try the subdomain install after you confirm me via email preferred.

    Thanks,


    _ck_
    Participant

    @_ck_

    cordoval, there are several dozen bbPress sites on my top1000 list that use subdomains, hence I know it works. Please stop using this incorrect topic for the subject matter, thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar