URLs and redirects

5 views
Skip to first unread message

Michael C. Harris

unread,
Dec 20, 2007, 9:55:29 PM12/20/07
to Habari Users
I'm slowly reducing the blocks to moving to Habari, when I have the
time. My current issue is URLs. I have my current blog set up using
date based permalinks:

www.example.com/2007/12/21/this-is-the-slug

Habari imports this as:
www.example.com/this-is-the-slug

I quite like the date based URL because it's got a built-in temporal
context. Is this possible in Habari?

If I can't have that, what are my redirect options? I would think the
best option is a 301 Moved Permanently. Has someone done this already?

cheers, Michael

Owen Winkler

unread,
Dec 21, 2007, 8:39:14 AM12/21/07
to habari...@googlegroups.com
Michael C. Harris wrote:
> I'm slowly reducing the blocks to moving to Habari, when I have the
> time. My current issue is URLs. I have my current blog set up using
> date based permalinks:
>
> www.example.com/2007/12/21/this-is-the-slug
>
> Habari imports this as:
> www.example.com/this-is-the-slug
>
> I quite like the date based URL because it's got a built-in temporal
> context. Is this possible in Habari?

My site displays active custom rewrite rules I have added to the
rewrite_rules table as insert statements at this URL:

http://asymptomatic.net/rewrite_rulez

If you remove this parameter from the regex:
(?P<id>\\d+)/

And this part from the build string:
{$id}/

That will get you the URLs you are looking for. Habari will also
continue to answer for URLs with the slug at the root.

Owen

Funky Larma

unread,
Jan 7, 2008, 5:01:32 PM1/7/08
to habari-users
Hi Owen I just tried your rewrite rules but it is not working.
The links are being created correctly but during the page loading the
link url changes to www.example.com/2007/{$mon0}/{$mday0}/this-is-the-slug
which is obviously chucking up a property of a non object.
Unless I'm missing something, which is quite possible as this is my
first dive into Habari. Think I might do a bit of reading first ;)

Chris Starjive

unread,
Jan 7, 2008, 5:57:35 PM1/7/08
to habari-users
Maybe this this code will help you out..

INSERT INTO rewrite_rules (name, parse_regex, build_str, handler,
action, priority, is_active, rule_class, description) VALUES
('display_entry', '%(?P<year>\\d{4})/(?P<mon0>\\d{2})/(?P<mday0>\
\d{2})/(?P<slug>[^/]+)[/]{0,1}$%i', '{$year}/{$mon0}/{$mday0}/
{$slug}', 'UserThemeHandler', 'display_post', '8', '1', '0', '');

On Jan 7, 11:01 pm, Funky Larma <funkyla...@googlemail.com> wrote:
> Hi Owen I just tried your rewrite rules but it is not working.
> The links are being created correctly but during the page loading the
> link url changes towww.example.com/2007/{$mon0}/{$mday0}/this-is-the-slug

rickc

unread,
Jan 8, 2008, 4:26:04 PM1/8/08
to habari-users
As written, Chis and Owen's rewrite rules didn't work for me
(using SQLite). But if I changed all '\\' to '\', they worked fine.

Funky Larma

unread,
Jan 9, 2008, 2:19:19 AM1/9/08
to habari-users
Nope I'm still getting the url changed during loading.
Could it be a Dreamhost issue, it normally is!

Funky Larma

unread,
Jan 23, 2008, 4:31:52 AM1/23/08
to habari-users
Right I have solved the changing of the url during load, it was a mess
up between Route301 and the re-write rules for Habari.
So now all url's are changed to the new style and they stay that way
during load but now I'm getting an "Uncaught Exception: Exception:
Trying to get property of non-object" error on page load.

Any ideas?

Michael C. Harris

unread,
Jan 23, 2008, 10:16:12 PM1/23/08
to habari...@googlegroups.com
On Wed, Jan 23, 2008 at 01:31:52AM -0800, Funky Larma wrote:
>
> Right I have solved the changing of the url during load, it was a mess
> up between Route301 and the re-write rules for Habari.
> So now all url's are changed to the new style and they stay that way
> during load but now I'm getting an "Uncaught Exception: Exception:
> Trying to get property of non-object" error on page load.

Put the following line at the bottom of your config.php

define( 'DEBUG', true );

Now access your site. You should get a comprehensive error message to
post here.

cheers, Michael

--
Michael C. Harris, School of CS&IT, RMIT University
http://twofishcreative.com/michael/blog

Funky Larma

unread,
Jan 28, 2008, 10:46:32 AM1/28/08
to habari-users
Sorry for the late reply, but here goes:

Uncaught Exception: Exception: Trying to get property of non-object
#0 in system/classes/userthemehandler.php:36:
Error::error_handler(
8,
'Trying to get property of non-object',
'/home/.hollywood/funkylarma/habari.shibbyonline.co.uk/system/
classes/userthemehandler.php',
36,
array (
'action' => 'display_404',
'request' =>
stdClass::__set_state(array(
)),
'rule' =>
RewriteRule::__set_state(array(
'entire_match' => NULL,
'named_arg_values' =>
array (
),
'm_named_args' => NULL,
'fields' =>
array (
'rule_id' => 0,
'name' => 'atompub_servicedocument',
'parse_regex' => '%^atom$%i',
'build_str' => 'atom',
'handler' => 'AtomHandler',
'action' => 'introspection',
'priority' => 1,
'is_active' => 1,
'rule_class' => 0,
'description' => 'Atom introspection',
),
'newfields' =>
array (
),
'unsetfields' =>
array (
...)
#1 in system/classes/controller.php:180:
UserThemeHandler->act(
'display_404'
)
#2 in index.php:186:
Controller::dispatch_request()

On Jan 24, 3:16 am, "Michael C. Harris" <michael.twof...@gmail.com>
wrote:

Owen Winkler

unread,
Jan 28, 2008, 10:47:00 AM1/28/08
to habari...@googlegroups.com
Funky Larma wrote:
> Sorry for the late reply, but here goes:
>
> Uncaught Exception: Exception: Trying to get property of non-object
> #0 in system/classes/userthemehandler.php:36:

I believe that this error has been corrected in the svn HEAD version of
Habari. Can you try updating or installing the latest development
version from http://habariproject.org/dist ?

Owen

Reply all
Reply to author
Forward
0 new messages