Recent Topics

1 Jan 11, 2009 07:56    

My b2evolution Version: 2.x

Is there a limit to the number of characters that you can have in the URL filename/permalink?

I use <em> tags in a lot of my post titles and if b2evolution generates the permalink, it adds "em" where the tags are. So I've been manually entering them in the URL "filename" dialog box. But I recently did a long title that seemed to get cut off and then had a colon placed at the end. Clicking the title or "leave a comment" link led to a "page cannot be found" error. (I went ahead and truncated the name so the permalink would work.)

So is there a limit to the character count for the URL/permalink and if so, what is it? And if there isn't one, any ideas of what might have happened?

Thanks.

2 Jan 11, 2009 09:41

There is a 40 character limit on the url length ( inc/items/model/_item.funcs.php approx 132 )

	// Normalize to 40 chars + a number
	preg_match( '/^(.*?)((-|_)+([0-9]+))?$/', $urltitle, $matches );
	$urlbase = substr( $matches[1], 0, 40 );
	$urltitle = $urlbase;
	if( ! empty( $matches[4] ) )
	{
		$urltitle = $urlbase.'-'.$matches[4];
	}

¥
note to self : add strip tags to auto generated urls

3 Jan 11, 2009 23:23

¥åßßå wrote:

There is a 40 character limit on the url length ( inc/items/model/_item.funcs.php approx 132 )

	// Normalize to 40 chars + a number
	preg_match( '/^(.*?)((-|_)+([0-9]+))?$/', $urltitle, $matches );
	$urlbase = substr( $matches[1], 0, 40 );
	$urltitle = $urlbase;
	if( ! empty( $matches[4] ) )
	{
		$urltitle = $urlbase.'-'.$matches[4];
	}

¥
note to self : add strip tags to auto generated urls

Thanks, ¥åßßå. Would I be correct in assuming that changing the 40 in the urlbase line would change this limit? As I mentioned in another post, I know just enough php to be dangerous. ;)

4 Jan 12, 2009 09:40

The highest you can go ( without changing the database column ) is 50, however, you either need to ensure that your urls are unique or keep them to 48 characters so that evo has room to add numbers if required to make them unique ;)

¥

5 Jan 13, 2009 03:05

¥åßßå wrote:

The highest you can go ( without changing the database column ) is 50, however, you either need to ensure that your urls are unique or keep them to 48 characters so that evo has room to add numbers if required to make them unique ;)

Thanks for the additional info and warning. I'll probably go ahead and bump the number up to 50. (The post title that originally caused this problem would've exceeded this number anyway.) I'm certainly not about to go messing with the database tables. I want to learn php/sql, but not by wrecking my blog. ;)

6 Apr 14, 2009 15:52

To refresh my memory, the table to alter the number in is "Table: evo_items__item post_url", correct?

8 Jun 21, 2009 20:14

I suppose changing the character limit will break old links?

9 Jun 21, 2009 20:23

nomad wrote:

I suppose changing the character limit will break old links?

I don't think it does.

10 Jun 21, 2009 20:49

nomad wrote:

I suppose changing the character limit will break old links?

It shouldn't/doesn't.

11 Jun 21, 2009 20:54

ah ok, i see. i thought it would change old links (makes them longer), but it doesn't


Form is loading...