Basically, I would set up a table similar to the following:
Code: Select all
CREATE TABLE 'pages' (
'pageId' int(10) NOT NULL auto_increment,
'pageTitle' varchar(200) NOT NULL,
'pageDescription' text NOT NULL,
'pageKeywords' text NOT NULL,
'pageCleanUrl' varchar(200) NOT NULL,
'pageType' varchar(100) NOT NULL,
PRIMARY KEY ('pageId'),
UNIQUE ('pageCleanUrl')
)A URL without any rewriting would look like:
http://www.site.com/index.php?p=blog/my ... -blog-post
With URL rewriting, it would look like:
http://www.site.com/blog/my-latest-blog-post
In this case, I would get the parameter, validate it, sanitize it, and then run a query for it. The resulting 'pageId' (which would be used as a foreign index in multiple tables) would then act as a direction for the controller for all of the various pieces of page content, telling the page which parts to load.
Some of the advantages would be that the rewrite rule would be fairly simple and I could easily edit metadata or apply tags for any page on my site. Even without rewriting, the URL is at least somewhat readable. The main disadvantage I wonder about is security. If I check to make sure that only alphanumeric characters, a forward slash, hyphen, and underscore are the only characters used and if I bind the input as a parameter using PDO, will I have any security problems? Are there any performance or other problems to this approach? Does anyone have or can they point to better practices?