|
Автор Administrator
|
|
23 ноември 2005 |
|
Тук можете да разгледате още един вариант SEF като използваме modRewrite
В файла index.php след реда: require_once( "includes/frontend.php" ); добавяме ред: require_once( "includes/urls.php" ); В края на този файл заменяме: } else { ob_end_flush(); } На: } else { $contents = ob_get_contents(); // store buffer in $contents ob_end_clean(); // delete output buffer and stop buffering echo replace_for_mod_rewrite($contents); //display modified buffer to screen } Създаваме файл includes/urls.php: <?php function replace_for_mod_rewrite(&$s) { $urlin = array( "'(?<!/)index.php'", "'(?<!/)index.html?option=content&task=view&id=12&Itemid=35'", "'(?<!/)index.html?option=content&task=view&id=2&Itemid=25'", "'(?<!/)index.html?option=content&task=view&id=3&Itemid=26'", ); $urlout = array( "index.html", "about/", "hosting/", "hosting/tariffs/", ); $s = preg_replace($urlin, $urlout, $s); return $s; } ?> И в .htaccess добавяме следното: RewriteEngine On RewriteRule index.html index.php RewriteRule about(/?)$ index.php?option=content&task=view&id=12&Itemid=35 RewriteRule hosting(/?)$ index.php?option=content&task=view&id=2&Itemid=25 RewriteRule hosting/tariffs(/?)$ index.php?option=content&task=view&id=3&Itemid=26 (htaccess.txt трябва да бъде преименуван на .htaccess) Вижте внимателно синтаксиса!
|