Hey all,
I am planning to migrate to SilverStripe and the SilverStripe blog module. It will take time. The SilverStripe devs hooked me up by getting the wordpress importer working.
My issue:
I am currently using Wordpress. My WP blog has URLs with dates such as:
http://site/2010/11/25/some-post
There are a lot of links in Forums and other blogs that point to my blog and I don't want these links to be broken.
But I imported my WP posts into SS and SS does not have dates in the URL. Instead, SS seems to require that the blog be a subdir of the root, so the same blog on SS is this:
http://site/Myblog/some-post
I want to implement a single piece of code to redirect
Proposed Solution
I need to implement the following logic:
IF PageNotFound
If Date is in URL (http://site/2010/11/26/some-post)
replace date portion of url (2010/11/26) with blogname (MyBlog)
redirect to new URL (http://site/blogname/some-post)
endif
endif
I have some php code that implements this logic in a rudimentary fashion:
<?php
$blogname = "blog";
$url = $_SERVER[SCRIPT_NAME];
$slashcount = substr_count($url, '/');
if ($slashcount = 4) { // this if statement could be improved maybe using regex
$url = strrchr($url, "/");
}
header('Location: /' . $blogname . $url ) ;
?>
Anyway, I think this solution would work for me. When someone clicks on a link, they would get the correct blog post.
What I need help with
It seems that SS has code to load to = "Page not found".
If I knew where in the code to load "Page not found" was, I could probably make this change myself. Maybe I could learn something from how "Page not found" is loaded and do some similar saphire/silverstripe logic that is more elegant.