[HACK]Get "YYYY/MM/DD" out of your permalink URLs

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.   printer-friendly view    b2evolution Forum Index -> Obsolete Forum Threads
View previous topic :: View next topic  
Author Message
isaac
Hooked :)
Hooked :)

Joined: 03 Dec 2003
Posts: 428
Reputation: 46.9Reputation: 46.9Reputation: 46.9Reputation: 46.9Reputation: 46.9 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Mon Jul 26, 2004 14:00    Post subject: [HACK]Get "YYYY/MM/DD" out of your permalink URLs Reply with quote

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:
Code:
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:
Code:
<?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:
Code:
$permalink = url_add_tail( $blogurl, mysql2date("/Y/m/d/", $post_date).$urltail );
to this:
Code:
$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.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
isaac
Hooked :)
Hooked :)

Joined: 03 Dec 2003
Posts: 428
Reputation: 46.9Reputation: 46.9Reputation: 46.9Reputation: 46.9Reputation: 46.9 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Aug 03, 2004 19:05    Post subject: Reply with quote

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
Code:
      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:
Code:
      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.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
p3bundles
New Poster
New Poster

Joined: 25 Jan 2006
Posts: 4
Reputation: 3.4Reputation: 3.4Reputation: 3.4 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Jan 26, 2006 0:36    Post subject: Reply with quote

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

Thanks for your help.
Back to top
View user's profile Send private message
raspb3rry
New Poster
New Poster

Joined: 28 Nov 2005
Posts: 26
Reputation: 5.8Reputation: 5.8Reputation: 5.8Reputation: 5.8Reputation: 5.8 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Wed Feb 08, 2006 23:07    Post subject: Reply with quote

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

Thanks for your help.


This hack should work for 1.6: http://www.deadbeef.com/index....permalinks

Does anyone know if the hack posted by isaac works with v 0.9.0.12?
Back to top
View user's profile Send private message Visit poster's website
fares
New Poster
New Poster

Joined: 22 Jun 2009
Posts: 6
Reputation: 8.4Reputation: 8.4Reputation: 8.4Reputation: 8.4Reputation: 8.4Reputation: 8.4Reputation: 8.4Reputation: 8.4 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Feb 25, 2010 8:22    Post subject: Reply with quote

what about b2evo 3.3.x ???
Back to top
View user's profile Send private message
Walter
Hooked :)
Hooked :)

Joined: 11 May 2004
Posts: 416
Reputation: 114.2 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 5

PostPosted: Thu Feb 25, 2010 8:26    Post subject: Reply with quote

in 3.x this is bundled, just change your blog URL settings
_________________
[]'s
- Walter
http://b2evolution.waltercruz.com
Back to top
View user's profile Send private message Visit poster's website
sam2kb
da ruski mafia

Joined: 02 Dec 2007
Posts: 2927
Reputation: 162.4Reputation: 162.4 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 53

PostPosted: Thu Feb 25, 2010 16:34    Post subject: Reply with quote

How come the thread created 6 years ago is not in "Obsolete stuff" forum yet Shocked
Such posts confuse newcomers http://forums.b2evolution.net/...436#100436

_________________
Russian b2evolution | Download
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.   printer-friendly view    b2evolution Forum Index -> Obsolete Forum Threads All times are GMT - 5 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board