Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Created July 17, 2012 13:42
Show Gist options
  • Save JossWhittle/3129458 to your computer and use it in GitHub Desktop.
Save JossWhittle/3129458 to your computer and use it in GitHub Desktop.
HTACCESS file with URL Rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^post/([0-9]+)(:?\/[a-zA-Z0-9_]*)?(:?\/.*)?$ /index.php?id=$1
RewriteRule ^post/([a-zA-Z]+)/([0-9]+)(:?\/[a-zA-Z0-9_]*)?(:?\/.*)?$ /index.php?filter=$1&value=$2
<?php
// Parses the title string to make it url/seo friendly
// Returns thed scrubbed string
function parseTitle($str) {
$str = preg_replace("/[^a-zA-Z0-9_\s]+/i", '', $str);
$str = preg_replace("/\s+/i", '_', $str);
return $str;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment