Monday, March 26, 2012

Permalink Structure

I have been creating a personal blog engine for the last couple of weeks
because I am tired of using WordPress and I don't have a SQL server
back-end. I have successfully created a working URL rewriting engine
(via Global.asax) that cleans illegal characters from the post title,
uses Regular Expressions to grab the entryID (ie 13), rewrite the path
(entry.aspx?entryID=13).

My current permalink structure is as follows:

root/blog/testing-post-example-00013.aspx

I have noticed that some blog engines have the following schemas for
their permalink structures:

root/blog/testing-post-example/00013.aspx

I have tried to create this structure programmatically with the
following code:

string EntryTitle = "testing-post-example";
string PermaLink = EntryTitle + "/" + "000" + EntryID + ".aspx";

When I try to run this I get the error that the file can't be found,
obviously. There must be a way to create this link structure without
having to physically create the directories. I can't imagine that all
of these bloggers login and create a directory for each post and place a
"showEntry.aspx" file in there.

Any suggestions?

- Will

*** Sent via Developersdex http://www.developersdex.com ***Nevermind!

Original RewritePath
httpContext.RewritePath("entry.aspx?entryID=" + pageID);

New RewritePath
httpContext.RewritePath("/entry.aspx?entryID=" & pageID)

No wonder it was FILE NOT FOUND (enry.aspx). Instead of looking in the
root directory (actual location) for entry.aspx it was looking for
entry.aspx in the dynamically created "directory" folder.

*** Sent via Developersdex http://www.developersdex.com ***

0 comments:

Post a Comment