bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

Url Rewriting Problem

(4 posts)
  • Started 9 months ago by fikirbozan
  • Latest reply from Nightgunner5
  • This topic is not resolved

Tags:

  1. How can we get rid of topic or forum in the permanent links

    My links like
    http://www.mysite.com/topic/wordpress-theme/

    But i want like
    http://www.mysite.com/wordpress-theme/

    and
    my forums links
    http://www.mysite.com/forum/wordpress/
    but i want like
    http://www.mysite.com/wordpress/

    how can i do this

    Posted 9 months ago #
  2. The short answer is that you can't.

    bbPress would have no way to tell whether it was searching for a topic or a forum.

    Posted 9 months ago #
  3. instead of this can i change topic to konu ('konu' is translation of topic in Turkish )

    Posted 9 months ago #
  4. Yes, you would need to go into your .htaccess file, plus something to make sure topic links went there... I'll look into it.

    Here it is:

    Go into your bb-includes/template-functions.php. Find the function called get_topic_link, it should look like this:

    function get_topic_link( $id = 0, $page = 1 ) {
    	$topic = get_topic( get_topic_id( $id ) );
    
    	$args = array();
    
    	$rewrite = bb_get_option( 'mod_rewrite' );
    	if ( $rewrite ) {
    		if ( $rewrite === 'slugs' ) {
    			$column = 'topic_slug';
    		} else {
    			$column = 'topic_id';
    		}
    		$link = bb_get_option('uri') . "topic/" . $topic->$column . ( 1 < $page ? "/page/$page" : '' );
    	} else {
    		$link = bb_get_option('uri') . 'topic.php';
    		$args['id'] = $topic->topic_id;
    		$args['page'] = 1 < $page ? $page : false;
    	}
    
    	if ( $args )
    		$link = add_query_arg( $args, $link );
    
    	return apply_filters( 'get_topic_link', $link, $topic->topic_id );
    }

    Change 'topic/' to 'konu/'.

    Now, go into your .htaccess file. If you're using Options +MultiViews, I don't know how this will work, but if you're using mod_rewrite, here's what to do:

    Find the lines that look like

    RewriteRule ^topic/([^/]+)/page/([0-9]+)/?$ /[YOUR FORUM DIRECTORY]/topic.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^topic/([^/]+)/?$ /[YOUR FORUM DIRECTORY]/topic.php?id=$1 [L,QSA]

    and change them to

    RewriteRule ^konu/([^/]+)/page/([0-9]+)/?$ /[YOUR FORUM DIRECTORY]/topic.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^konu/([^/]+)/?$ /[YOUR FORUM DIRECTORY]/topic.php?id=$1 [L,QSA]

    I think that's all you'll need to do...

    Posted 9 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.