| View previous topic :: View next topic |
| Author |
Message |
isaac Hooked :)

Joined: 03 Dec 2003 Posts: 428
     
|
Posted: Mon Jul 26, 2004 14:00 Post subject: [HACK]Get "YYYY/MM/DD" out of your permalink URLs |
|
|
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 |
|
 |
isaac Hooked :)

Joined: 03 Dec 2003 Posts: 428
     
|
Posted: Tue Aug 03, 2004 19:05 Post subject: |
|
|
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 |
|
 |
p3bundles New Poster

Joined: 25 Jan 2006 Posts: 4
   
|
Posted: Thu Jan 26, 2006 0:36 Post subject: |
|
|
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 |
|
 |
raspb3rry New Poster

Joined: 28 Nov 2005 Posts: 26
     
|
Posted: Wed Feb 08, 2006 23:07 Post subject: |
|
|
| 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 |
|
 |
fares New Poster

Joined: 22 Jun 2009 Posts: 6
        
|
Posted: Thu Feb 25, 2010 8:22 Post subject: |
|
|
| what about b2evo 3.3.x ??? |
|
| Back to top |
|
 |
Walter Hooked :)

 Joined: 11 May 2004 Posts: 416
  votes: 5
|
Posted: Thu Feb 25, 2010 8:26 Post subject: |
|
|
in 3.x this is bundled, just change your blog URL settings _________________ []'s
- Walter
http://b2evolution.waltercruz.com |
|
| Back to top |
|
 |
sam2kb da ruski mafia
Joined: 02 Dec 2007 Posts: 2927
   votes: 53
|
|
| Back to top |
|
 |
|