Skip to:
Content
Pages
Categories
Search
Top
Bottom

[resolved] Problems setting up my two different .htaccess

  • Hey!

    I finally setup bbpress inside http://example.com/forum/

    Of course I would like to use permalinks, because they are already working with my WordPress-Blog http://example.com

    I am not a specialist in setting up .htaccess, so I would like to request your help.

    The “main” .htacess reads as follows:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    Redirect permanent /zsblog http://example.com
    Redirect permanent /zsblog/feed/ http://example.com/feed/

    As you can see my blog runs inside /zsblog which is located in / on my server.

    bbpress runs inside /zsblog/forum

    Here the .htaccess of “bbpress”:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /forum
    RewriteRule ^forum/([^/]+)/page/([0-9]+)/?$ /forum.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^forum/([^/]+)/?$ /forum.php?id=$1 [L,QSA]
    RewriteRule ^topic/([^/]+)/page/([0-9]+)/?$ /topic.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^topic/([^/]+)/?$ /topic.php?id=$1 [L,QSA]
    RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ /tags.php?tag=$1&page=$2 [L,QSA]
    RewriteRule ^tags/([^/]+)/?$ /tags.php?tag=$1 [L,QSA]
    RewriteRule ^tags/?$ /tags.php [L,QSA]
    RewriteRule ^profile/([^/]+)/page/([0-9]+)/?$ /profile.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^profile/([^/]+)/([^/]+)/?$ /profile.php?id=$1&tab=$2 [L,QSA]
    RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ /profile.php?id=$1&tab=$2&page=$3 [L,QSA]
    RewriteRule ^profile/([^/]+)/?$ /profile.php?id=$1 [L,QSA]
    RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ /view.php?view=$1&page=$2 [L,QSA]
    RewriteRule ^view/([^/]+)/?$ /view.php?view=$1 [L,QSA]
    RewriteRule ^rss/?$ /rss.php [L,QSA]
    RewriteRule ^rss/forum/([^/]+)/?$ /rss.php?forum=$1 [L,QSA]
    RewriteRule ^rss/topic/([^/]+)/?$ /rss.php?topic=$1 [L,QSA]
    RewriteRule ^rss/tags/([^/]+)/?$ /rss.php?tag=$1 [L,QSA]
    RewriteRule ^rss/profile/([^/]+)/?$ /rss.php?profile=$1 [L,QSA]
    </IfModule>

    Unfortunately, when clicking on a new created forum or on a topic I get redirects to random(?) articles inside my WordPress-Blog.

    Any ideas how I can fix that?

    BTW.: Option +MultiViews didn’t work for me. Need to set it up separately.

    Thanks in advance!

    All the best,

    lynx

Viewing 4 replies - 1 through 4 (of 4 total)

  • kevinjohngallagher
    Member

    @kevinjohngallagher

    Ok i think i see the problem, but off the top of my head don’t know how to fix it (am writing from my phone).

    Basically what you want to do is add “/forum/” to the expetion rules you’ve already listed (-f and -d) and have it redirect/pull the pages from /zsblog/forum/.

    basically this line: RewriteCond %{REQUEST_FILENAME} !-d checks if a directory exists, if it does then it ignores the htaccess, if not, then it triggers the condition (in this case loading wordpress).

    Because /forum/ does not physically exist, it fires wordpress which will try to parse the URL into a blog post.

    Oh wow, i just had an amazing amazing brainwave.

    Why not write a function that filters URLS so include your bbPress one instead of your wordpress ones if “/forum/” is used. Given that it would load after all the WP processing this would solve COUNTLESS bbPress problems. You know, i might have solved wordPress and bbPress integreation.

    @kevin

    What have you possibly solved?


    kevinjohngallagher
    Member

    @kevinjohngallagher

    Ok, i’m coding on my iPhone – expect errors.

    function kjg_custom_feed_rewrite($wp_rewrite)

    {

    $feed_rules = array

    (

    ‘forum/(.+)/(.+)’ => ‘/bbpress_folder/index.php?variable1=’ . $wp_rewrite->preg_index(1) . ‘&variable2=’ . $wp_rewrite->preg_index(2),

    );

    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;

    }

    add_filter(‘generate_rewrite_rules’, ‘kjg_custom_feed_rewrite’);

    function kjg_add_custom_page_variables( $public_query_vars )

    {

    $public_query_vars[] = ‘variable1’;

    return $public_query_vars;

    }

    add_filter( ‘query_vars’, ‘kjg_add_custom_page_variables’ );

    Basically, whenever you try and load “domain.com/forum” the .htaccess file would load wordpress. WordPress then hits it’s own htaccess rules (how it does permalinks etc), which it stores as an array you can manipulate and it then loads the page you tell it with the $_GET variables you can also maipulate. The thing is, WordPress does this AFTER it’s loaded it’s variables and plugins, but obviously before it’s done any form of outputting to the screen… so in theory you could just tell it to load the bbpress index instead, and as it’s already got wp-load.php processed, all of the user-ids/logins/permissions etc should be already generated – not to mention, you could call WP functions etc.

    Basically, it’s deep integration but form the WordPress side rather than the bbpress side. There might be some BackPress function un-compatability (i can think of a few right now that would be iffy) – but it basically looking at the problem from a different viewpoint.

    Instead of trying to bridge WordPress and bbpress, why not have WordPress load bbPress as a “plugin”, and then we could take advantage of plugins like WP-Role-manager and facebook connect etc.

    Ok, my code may be very very wrong, give me a day to hack out something :)

    Okay, I think I solved it myself.

    The working code is as follows:

    # BEGIN bbPress

    #Options +MultiViews

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /forum/

    RewriteRule ^page/([0-9]+)/?$ /forum/index.php?page=$1 [L,QSA]
    RewriteRule ^forum/([^/]+)/page/([0-9]+)/?$ /forum/forum.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^forum/([^/]+)/?$ /forum/forum.php?id=$1 [L,QSA]
    RewriteRule ^forum/?$ /forum/ [R=302,L,QSA]
    RewriteRule ^topic/([^/]+)/page/([0-9]+)/?$ /forum/topic.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^topic/([^/]+)/?$ /forum/topic.php?id=$1 [L,QSA]
    RewriteRule ^topic/?$ /forum/ [R=302,L,QSA]
    RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ /forum/tags.php?tag=$1&page=$2 [L,QSA]
    RewriteRule ^tags/([^/]+)/?$ /forum/tags.php?tag=$1 [L,QSA]
    RewriteRule ^tags/?$ /forum/tags.php [L,QSA]
    RewriteRule ^profile/([^/]+)/page/([0-9]+)/?$ /forum/profile.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^profile/([^/]+)/([^/]+)/?$ /forum/profile.php?id=$1&tab=$2 [L,QSA]
    RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ /forum/profile.php?id=$1&tab=$2&page=$3 [L,QSA]
    RewriteRule ^profile/([^/]+)/?$ /forum/profile.php?id=$1 [L,QSA]
    RewriteRule ^profile/?$ /forum/profile.php [L,QSA]
    RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ /forum/view.php?view=$1&page=$2 [L,QSA]
    RewriteRule ^view/([^/]+)/?$ /forum/view.php?view=$1 [L,QSA]
    RewriteRule ^rss/?$ /forum/rss.php [L,QSA]
    RewriteRule ^rss/topics/?$ /forum/rss.php?topics=1 [L,QSA]
    RewriteRule ^rss/forum/([^/]+)/?$ /forum/rss.php?forum=$1 [L,QSA]
    RewriteRule ^rss/forum/([^/]+)/topics/?$ /forum/rss.php?forum=$1&topics=1 [L,QSA]
    RewriteRule ^rss/topic/([^/]+)/?$ /forum/rss.php?topic=$1 [L,QSA]
    RewriteRule ^rss/tags/([^/]+)/?$ /forum/rss.php?tag=$1 [L,QSA]
    RewriteRule ^rss/tags/([^/]+)/topics/?$ /forum/rss.php?tag=$1&topics=1 [L,QSA]
    RewriteRule ^rss/profile/([^/]+)/?$ /forum/rss.php?profile=$1 [L,QSA]
    RewriteRule ^rss/view/([^/]+)/?$ /forum/rss.php?view=$1 [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ /forum/index.php [L]
    </IfModule>

    # END bbPress

    As you can see, I commented the Options +MultiViews out and let the bbpress-generated .htaccess do the rest.

    I was just lucky and experimenting with different .htaccess in this subfolder for hours.

    Thanks anyway!

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