Skip to:
Content
Pages
Categories
Search
Top
Bottom

Permalinks setup with WP intalled in subdirectory and index.php in root


  • Gianfranco
    Participant

    @gian-ava

    am running WP 2.9.2 / BP 1.2.2.1 and I got WP installed in a subdirectory (with index.php and .htaccess in the root).

    Everything works as it should, except for this problem, which is probably due to the installation setup being in a subfolder, since other are experiencing problems with the same a setup.

    I’d like to sort a few things out with such a setup, since I believe many are those who got WP in a subdirectory.

    First, with WP installed in a subfolder you got this settings, right?:

    • Site URL: http://mysite.com/folder

    • BLog URL: http://mysite.com/folder

    The results is that you have a permalin structure such as:

    • http://mysite.com/page

    • http://mysite.com/post

    • and so on…

    The problem is that whenever you navigate within the web pages generated by BP (you are in a BP component), you get this:

    • http://mysite.com/folder/activity

    • http://mysite.com/folder/members

    • and so on…

    Is there a way to have the same permalink structure as in WP pages?

    Optionally, and ideally, would it be possible to have everything within BP to display with a base name? Like if you are running a regular site and want to create/enable a section of the site (not the whole site) for social network (BP components), that everything displays for example as:

    • http://mysite.com/socialnetwork/activity

    Thanks for helping. I am sure this is a piece of information useful to many.

Viewing 25 replies - 1 through 25 (of 45 total)

  • Gianfranco
    Participant

    @gian-ava

    I am not totally comfortable with changing stuff in core files, without some guru out there telling me what to do, but is it possible that to solve the issue one needs to customize bp-core.php?

    These particular lines grabbed my attention. Again, I am not going to play with it, before any good advise.

    Line 95:

    /* The domain for the root of the site where the main blog resides */

    $bp->root_domain = bp_core_get_root_domain();

    Line 608:

    /**

    * bp_core_get_root_domain()

    *

    * Returns the domain for the root blog.

    * eg: http://domain.com/ OR https://domain.com

    *

    * @package BuddyPress Core

    * @uses get_blog_option() WordPress function to fetch blog meta.

    * @return $domain The domain URL for the blog.

    */

    function bp_core_get_root_domain() {

    global $current_blog;

    if ( defined( ‘BP_ENABLE_MULTIBLOG’ ) )

    $domain = get_blog_option( $current_blog->blog_id, ‘siteurl’ );

    else

    $domain = get_blog_option( BP_ROOT_BLOG, ‘siteurl’ );

    return apply_filters( ‘bp_core_get_root_domain’, $domain );

    }


    Gianfranco
    Participant

    @gian-ava

    Where are the gurus on this?

    Andy? Andrea? Anyone?

    …


    r-a-y
    Keymaster

    @r-a-y

    The easiest way off the top is to apply a filter to ‘bp_core_get_root_domain’ to remove the /folder/ subdirectory; this wouldn’t fix your existing activity stream items as they’re already cached in the db.

    There’s probably another way though.


    Gianfranco
    Participant

    @gian-ava

    Thanks, r-a-y.

    I have to admit that I wouldn’t know how to apply such a filter. I am sure it’s something basic, but it’s just not something I use to do. Could you share an example?

    Also, I am not sure what you mean that it wouldn’t fix the activity stream. Do you mean that for that component I will still get mysite/folder/activity?

    Otherwise, as you suspect too, I am sure there must be a CLEAN way of telling BP that everything is in “folder” but not to output that. Maybe a funfcion to put in function.php, so that the core BP installation is not modified and you don’t need to edit the core files everytime you update.

    Any thoughts?

    PS: it seems like others are scratching their heads off the same topic:

    https://buddypress.org/forums/topic/404-errors-when-installing-bp-with-wp-in-a-subdirectory


    Gianfranco
    Participant

    @gian-ava

    So, no news about this?

    I just realize that there is a mistake in my original post, about the WP Settings configuration.

    Here’s a real life example.

    The site I am working on is Cureuhoria.com (existing WP single 2.9.2).

    The BP installation serve for a social network section, called CureMates.

    WP is installed in a subfolder called site.

    Everything works fine.

    The problem is that whenever you are in BP components (CureMates section), and you navigate within BP components, you get URLs/permalinks with the subfolder in it: cureuphoria.com/site/activity

    I just want http://cureuphoria.com/activity

    WP settings actually are:

    Site URL: http://cureuphoria/site/

    BLog URL: http://cureuphoria.com

    Is it possible (create a function or something) to tell BP to refer to the Blog URL and not to the Site URL, so that URLs/permalinks are consistent within the whole site?

    Ideally (but maybe that is asking too much) I’d like to run BP components from a folder called CureMates, so that URLs/permalinks are:

    http://cureuphoria.com/curemates/activity

    http://cureuphoria.com/curemates/members

    …and so on…

    Which would make the most sense and it’d be clear and clean for the user to know where they are.

    Am I the only one wanting something like that?

    Is that an impossible task to achieve?

    I feel some hints may be in the fuctions I listed above, but I just am not at the level of knowledge to play with this.

    Does anyone?


    Gianfranco
    Participant

    @gian-ava

    Nobody else interested in sorting this out?


    r-a-y
    Keymaster

    @r-a-y

    Thanks for bumping this, I totally forgot about this thread!

    bp_core_get_root_domain() uses the siteurl and not the blogurl.

    Please try adding this to wp-content/plugins/bp-custom.php:

    function my_bp_override_core_domain() {
    $domain = get_bloginfo('url');
    return $domain;
    }
    add_filter('bp_core_get_root_domain','my_bp_override_core_domain');

    I’m not 100% sure this will work and it might break your BP site or it might do nothing ;)

    If it breaks your site or if this doesn’t work, delete this snippet from bp-custom.php.

    If you want to run BP from the “curemates” subdirectory, login to the WP backend, and change the blog URL setting to “http://cureuphoria.com/curemates/”, then rename the “site” folder in your FTP to “curemates”

    This actually might be the easiest way to go about it. Try this method first!

    Again, I’m probably missing something in my steps. But that should give you at least a starting point.

    The rest you should be able to google up on the wp.org forums.


    Gianfranco
    Participant

    @gian-ava

    Hey r-a-y, thanks for replying and taking an interest in this.

    I will try the function out and let you know.

    As for the running BP in CureMates, I mean that since the whole site exists on its own, pages and blog, and I want to run the BP part as a SECTION of the existing site.

    So, that the site goes like this:

    cureuphoria.com

    cureuphoria.com/blog

    cureuphoria.com/links

    […]

    cureuphoria.com/curemates

    cureuphoria.com/curemates/activity

    cureuphoria.com/curemates/members

    Those are the BP components for the “social network” section of the site. Called CureMates.

    Mmh… does that make sense. If so, is it possible?


    r-a-y
    Keymaster

    @r-a-y

    I think the second method will do exactly what you want.

    More info here:

    https://codex.wordpress.org/Changing_The_Site_URL

    I would do a backup of everything just to be extra cautious!


    Gianfranco
    Participant

    @gian-ava

    Ok r-a-y, that actually worked like a charm!

    I thought that it was kind of a ridirect, but even when you mouse hover on links you don’t see the subfolder at all in status bar.

    That is so cool. Thanks a lot!

    Now, what about the other thing? Having CureMates so that users knows where they are?

    I very much appreciate your help.


    Gianfranco
    Participant

    @gian-ava

    I marked this as solved.

    Should I go and make another topic with the other request?


    r-a-y
    Keymaster

    @r-a-y

    If you want the “curemates” thing to work, I would remove the function snippet that I posted above and try the second method.

    Glad it works! Phew!

    [EDIT]

    Yeah sure make a new thread.


    Gianfranco
    Participant

    @gian-ava

    Oh, yeah, I see what you mean.

    That is the cheating way to achieve that. I’d go back to before the function thing, and change “site” with “curemates”.

    I may try that (yeah, backing up everything first). But isn’t there another way? Is evrybody running BP as a MAIN site rather than a subsection of a “regular” site?


    r-a-y
    Keymaster

    @r-a-y

    Yeah it is kind of a hack, isn’t it? :p

    Might want to post this in Trac:

    https://trac.buddypress.org/newticket

    Put something about using the blog URL vs. the WordPress URL for standard WP:

    https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory


    Gianfranco
    Participant

    @gian-ava

    Ok! I’ll do that.

    Anyway, I was maybe wrong about the links not pointing to a path with “site” bafore actually clicking. So do, some don’t. It can be a cache thing. Don’t know. But I can probably live with that.


    r-a-y
    Keymaster

    @r-a-y

    If it’s in the activity stream, then yes, it’s cached.

    You’ll have to manually change the entries in the DB or write up a few RewriteRules in .htaccess to redirect the old “site” urls.

    You could try this in .htaccess:

    RedirectMatch 301 ^/site/members/(.*)$ http://example.com/members/$1
    RedirectMatch 301 ^/site/groups/(.*)$ http://example.com/groups/$1
    RedirectMatch 301 ^/site/blogs/(.*)$ http://example.com/blogs/$1
    RedirectMatch 301 ^/site/forums/(.*)$ http://example.com/forums/$1

    Change example.com to your URL.

    This is if you’re still using the first method,.


    Gianfranco
    Participant

    @gian-ava

    Will it re-cahe sort of things at some point, by itself?

    Because there is no so much activity at thsi moment, so I don’t mind if later it fixes by itself.

    And the links do work with “site” in the URL, anyway. Not like you get a blank page.

    What you think?


    r-a-y
    Keymaster

    @r-a-y

    Oh okay… wasn’t sure if the “site” urls were giving you a 404.

    If it doesn’t give you a 404 , leave it as-is! If it ain’t broken, don’t fix it ;)

    [EDIT]

    Just checking out your site, it appears the “site” urls do not get redirected, they standalone on their own.

    You might want to apply the redirect rules I wrote above, otherwise you’ll have duplicate content. Not a big deal though if you don’t care about that.

    New activity stream entries will be correct. Old ones will not.


    Gianfranco
    Participant

    @gian-ava

    Well, I did apply the redirection rules, for the moment. It works fine.

    But I am considering just going and delete everything from the activity stream, since nobody is active on the site, for the moment. So I might as well go and restart the whole activity (basically just me).

    Duplicate stuff is not good for SEO and redirection slows things down in some occations.

    Tomorrow I’ll write a ticket in the TRAC as you suggested.


    r-a-y
    Keymaster

    @r-a-y

    Redirect in .htaccess doesn’t slow anything down.

    It’s really minimal.

    Starting from scratch would be best!


    sueme
    Participant

    @sueme

    I’m currently running an active site, and having followed the instructions in https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory I’ve got all my files in a mysite/wordpress file with everything in the wordpress folder but the index.php and .htaccess files in the home directory. that’s given the whole of my site a mysite address rather than a mysite/wordpress address.

    This sites been up a while and works well, but I’m having trouble getting BuddyPress to work on it. Whatever I try, I seem to end up with half the site still on mysite (whilst everything in mysite/wordpress is coming up unobtainable); or half the site on mysite/wordpress (whilst everything in mysite is unobtainable).

    Am I right in thinking that I can simply add the following to wp-content/plugins/bp-custom.php or is it more complicated than this?

    function my_bp_override_core_domain() {
    $domain = get_bloginfo('url');
    return $domain;
    }
    add_filter('bp_core_get_root_domain','my_bp_override_core_domain');

    There’s quite a bit of activity on the site, so I don’t want to start from scratch, but I would like to get BuddyPress on it.


    sueme
    Participant

    @sueme

    Didn’t get a reply so I tried it anyway. It didn’t work for me.

    1. The top of my page displayed the following message function my_bp_override_core_domain() { $domain = get_bloginfo('url'); return $domain; } add_filter('bp_core_get_root_domain','my_bp_override_core_domain')

    2. The buddypress folder still opened as mysite/wordpress rather than just mysite.


    r-a-y
    Keymaster

    @r-a-y

    You need to wrap that code in PHP open and close tags.

    eg.

    <?php
    function my_bp_override_core_domain() {
    $domain = get_bloginfo('url');
    return $domain;
    }
    add_filter('bp_core_get_root_domain','my_bp_override_core_domain');
    ?>


    sueme
    Participant

    @sueme

    Brilliant.

    Works well.

    Thank you so much.


    sueme
    Participant

    @sueme

    Actually. It all works well EXCEPT.

    When the home page link is clicked, it goes to mysite/wordpess and lists everything in that folder.

    Do you know how to change this please?

Viewing 25 replies - 1 through 25 (of 45 total)
  • The topic ‘Permalinks setup with WP intalled in subdirectory and index.php in root’ is closed to new replies.
Skip to toolbar