views:

151

answers:

2

I'm trying to figure out a generic permalinks structure for blogging, in order to be platform-independent. I know that Wordpress supports permalinks, and has some plugins for various permalinks style migration, but I also have to get it working in FlatPress and PivotX, and I don't have URL rewriting support in every place.

So far, I will try to use a folder like /permalinks/ into which an index.php file would redirect to the actual post, e.g. /permalinks/index.php?external-link-01 would redirect to /index.php/2009-02-03/external-link-01 or /index.php/e=42, based on the actual blogging platform being used.

For nicer permalinks, and to avoid URL rewriting, I could create a subfolder for each permalink (like /permalinks/external-link-01/), in which the default index file would do the redirection.

So,

  1. Is there a nicer way to maintain this kind of permalinks?
  2. What kind of redirect must I use?
  3. What can I do in order to allow bookmarking the permalink after the redirect? (e.g. the current page is /index.php/e=42 and the bookmark should be /permalinks/index.php?external-link-01)
+1  A: 

Why would want to create a bunch of folders with index files in them? That seems like it would become a real nightmare to manage in the longer term. Why do you want to avoid URL rewriting? Mod_rewrite seems like a clean and centralized and ultimately flexible system that will be easier to manage in the long term.

Not criticizing, just curious to understand the motivation of your project.

As for redirect I think you want do a

301 moved permanently

That way the redirect is understood correctly by the search engines. And you won't have errant urls lost in SEO land if your permalink system goes down.

You might also consider throwing in a URL shortening scheme in your system as well.

http://www.shauninman.com/archive/2009/08/17/less%5Fn

And if you have a system with multiple references to different URLs but the same content be sure not to forget about Canonical Links.

http://www.mattcutts.com/blog/canonical-link-tag/

Gordon Potter
1. URL rewriting support is not available on all hosting, and is not up to me to request it.
alexandrul
2. I want to keep the external links (to DZone, Digg and others) the same (/blog/permalink/fixed-link-01/) regardless of my blogging platform available at any given moment (like a migration from FlatPress to PivotX or the other way around)
alexandrul
Ok, makes sense. I would look up some of the URL shortening scripts and then customize those to support a permalink system. There is no rule that says a URL rewriter has to be short and crpytic. It seems if you go with a well planned RESTful type scheme you can avoid rewriting. Your permalink app can sit between the outside world and your blog. I would follow MVC. Where there is a simple front controller hub with a bunch of "dumb" index files.You can abstract the data model to either a database or a handful of data structures behind the scenes. Good luck! Curious to see what you create.
Gordon Potter
Thank you, you gave me a new perspective on the problem.
alexandrul
+1  A: 

You could potentially implement a fairly simply system based on folders with indexes all simlinked to a single php script which then is then tailored to redirect users to the article of choice (hint: you can implement this fairly easily using the url and preg_replace). This may have a slight performance hit when compared to mod_rewrite but it should be blogging platform independent and allow you to ensure that your links will never become broken (even if it even worse and your host does not allow simlinks, you could just copy the file).

ternaryOperator
For the moment I'm using folders with default documents that are redirecting to the required URL. Your solution is a lot easier to maintain +1
alexandrul