Recent Topics

1 Jul 26, 2004 21:00    

This involves modding some core files, so proceed at your own risk! These instructions apply to version 0.9.0.10, and may not be valid for other versions.

1. Run Apache, with mod_rewrite and extra path info. You must already be using extra path info (so your permalink URLs already look like stub/2004/07/25/url_title). This will also ONLY work if you're using stub files exclusively. The reason is that it won't be able to tell the difference between index.php/stub and index.php/url_title.

If you don't have this setup, it won't work, and there is no workaround at this time. I'm working on doing this in a cleaner fashion, without any mod_rewrite stuff, as it seems to do weird things to your referrals. (I'm getting a bunch from my own URL - it seems that every time the mod_rewrite happens, it logs a referrer hit from my own site!)

2. Put this in your .htaccess file:

RewriteEngine On

# Dateless permalinks: stub/url_title
RewriteRule ^([^/]+)/([A-Za-z0-9_]+)$  $1/0000/00/00/$2

3. Create a file called "hacks.php" and put it in your conf folder. Put this in it:

<?php
	if( !empty( $_SERVER['PATH_INFO'] ) && strpos($ReqURI, $_SERVER['PATH_INFO']) === false )
	{ // Path Info not found in ReqURI.
		$ReqPath = $ReqURI = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
//		echo "\$ReqURI = $ReqURI";
//		echo "\$ReqPath = $ReqPath";
	}
?>

4. Open up b2evocore/_class_item.php, on line 127, change it from this:

$permalink = url_add_tail( $blogurl, mysql2date("/Y/m/d/", $post_date).$urltail );

to this:

$permalink = url_add_tail( $blogurl, '/'.$urltail );

5. Just make sure that you're using the url_title permalinks, and you're all set! No more date in the URL.

2 Aug 04, 2004 02:05

Better way to do this:

1. Backup everything, and do everything in the other method, except for the .htaccess stuff.

2. Around line 117 of b2evocore/_blog_main.php, you'll find this

		elseif( isset( $path_elements[$i] ) && substr( $path_elements[$i], 0, 1 ) == 'w' )
		{	// We consider this a week number
			$w = substr( $path_elements[$i], 1, 2 );
		}
	}
}

Change that to this:

		elseif( isset( $path_elements[$i] ) && substr( $path_elements[$i], 0, 1 ) == 'w' )
		{	// We consider this a week number
			$w = substr( $path_elements[$i], 1, 2 );
		}
	}
	elseif( !empty( $path_elements[$i] ) 
					&& $path_elements[$i] != 'htsrv' 
					&& $path_elements[$i] != 'xmlsrv' 
					&& $path_elements[$i] != 'gettext' )
	{ // We'll consider this to be a ref to a post
		// We are accessing a post by permalink
		// Set a lot of defaults as if we had received a complex URL:
		// IZS - Moved here to do dateless permalinks.
		$m = '';
		$more=1;							// display the extended entries' text
		$c=1;									// Display comments
		$tb=1;								// Display trackbacks
		$pb=1;								// Display pingbacks

		if( ereg( "p([0-9]+)", $path_elements[$i], $req_post ) )
		{	// The last param is of the form p000
			// echo 'post number';
			$p = $req_post[1];		// Post to display
		}
		else
		{ // Last param is a string, we'll consider this to be a post urltitle
			$title = $path_elements[$i];
			// echo 'post title : ', $title;
		}
	}
}


Note that I added a section to handle the post title, if it's right after the stub name. Also, for some reason that I haven't yet found a clean way of doing, you need to test for those other options, as well as any other folder from which _blog_main.php might get called, or you'll get odd errors.

This makes the stats a lot cleaner than the mod_rewrite 0000/00/00 hackery.

3 Jan 26, 2006 06:36

Does this work using 1.6 phoenix?
Or is there another way of taking the date off the url?

Thanks for your help.

5 Feb 25, 2010 14:22

what about b2evo 3.3.x ???

6 Feb 25, 2010 14:26

in 3.x this is bundled, just change your blog URL settings


Form is loading...