Hello all, so I was tasked with looking into a way to rewrite our dynamic url's to something more user and seo friendly. I have absolutely no exprience in this area so it's been a lot of googling and trial and error. However; I've reached something of a wall in my research.
We're using apache so my research introduced me to mod_rewrite and htaccess files. I then created this little function in the php page that creates a new page - so that it's called whenever a page is created or edited.
function writeRule($dir, $id){
$text = file("../.htaccess");
$file = fopen("../.htaccess", 'w') or die(@mysql_error());
foreach($text as $line)
{
if (!strstr($line,$id)) //look for $id in each line
fputs($file,$line); //place $line back in file
}
$dir = str_replace(' ', '', $dir);
$dir = str_replace('/', '', $dir);
$dir = str_replace(',', '', $dir);
$dir = strtolower($dir);
$rule = "\nRewriteRule ^".$dir."/?$ index.php?id=".$id." [L]\n";
fwrite($file, $rule);
fclose($file);
}
However; my supervisor then tells me that she would rather not write directiy to the htaccess file AND further research told me that I probably shouldn't be doing it this way anyway. So I was basically back at the beginning, trying to find a way to rewrite the url's of pages - not only of the existing links but also on any new pages created by the client using the CMS later down road.
This led me to rewritemaps but we don't have access to the server config files to that's not really an option.
So I guess my question is what's the best practice for rewriting dynamic urls in an equally dynamic environment where you don't have access to server files?