Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Rewrite Mod for PHP-Fusion v6

Parašė cario· 2009 Vas. 19 16:02:44
#1

Daug kam reikėjo rewrite (friendly url) modo ant php-fusion.
Nutariau padaryti tokį simple.

Šį kodą dėkit į .htaccess failiuką:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(.*)$
RewriteRule ^straipsnis\.html$ articles.php [N]
RewriteRule ^straipsnis-kategorija-([0-9]+)\.html$ articles.php?cat_id=$1 [L]
RewriteRule ^skaityti-straipsni([0-9]+)\.html$ readarticle.php?article_id=$1 [L]
RewriteRule ^index\.html$ index.php [N]
RewriteRule ^muzika\.html$ downloads.php [N]
RewriteRule ^FAQ\.html$ faq.php [N]
RewriteRule ^nuoroda\.html$ weblinks.php [N]
RewriteRule ^kontaktai\.html$ contact.php [N]
RewriteRule ^fotoalbumas\.html$ photogallery.php [N]
RewriteRule ^ieskoti-forume\.html$ search.php?stype=f [N]
RewriteRule ^ieskoti\.html$ search.php [N]
RewriteRule ^narys-([0-9]+)\.html$ profile.php?lookup=$1 [L]
RewriteRule ^nuotraukos-albumas-([0-9]+)\.html$ photogallery.php?album_id=$1 [L]
RewriteRule ^nuotraukos-foto-([0-9]+)\.html$ photogallery.php?photo_id=$1 [L]
RewriteRule ^rodyti-nuotrauka-([0-9]+)\.html$ showphoto.php?photo_id=$1 [L]
RewriteRule ^muzika-kategorija-([0-9]+)\.html$ downloads.php?cat_id=$1 [L]
RewriteRule ^muzika-kategorija-([0-9]+)-daina-([0-9]+)\.html$ downloads.php?cat_id=$1&download_id=$2 [L]
RewriteRule ^FAQ-kategorija-([0-9]+)\.html$ faq.php?cat_id=$1 [L]
RewriteRule ^nuoroda-katalogas-([0-9]+)\.html$ weblinks.php?cat_id=$1 [L]
RewriteRule ^nuoroda-katalogas-([0-9]+)-strone-([0-9]+)\.html$ weblinks.php?cat_id=$1&weblink_id=$2 [L]
RewriteRule ^spausdinti-([0-9]+)\.html$ print.php?type=N&item_id=$1 [L]
RewriteRule ^spausdinti-stacia-([0-9]+)\.html$ print.php?type=A&item_id=$1 [L]
RewriteRule ^registracija\.html$ register.php [N]
RewriteRule ^slaptazodis\.html$ lostpassword.php [N]




Toliau susirandam maincore.php faile:

// Start Output Buffering
ob_start();




Ir keičiam į:

// Change links to F-url
function f_url($buf) {
if(!substr_count($_SERVER[REQUEST_URI],"administration")){
$buf = preg_replace('#readarticle\.php\?article_id=([0-9]*?)(\'|")#si', 'skaityti-straipsni\1.html\2', $buf);
$buf = preg_replace('#articles\.php\?cat_id=([0-9]*?)(\'|")#si', 'straipsnis-kategorija-\1.html\2', $buf);
$buf = preg_replace('#articles\.php#si', 'straipsnis.html', $buf);
$buf = preg_replace('#downloads\.php\?cat_id=([0-9]*?)(\'|")#si', 'muzika-kategorija-\1.html\2', $buf);
$buf = preg_replace('#downloads\.php\?cat_id=([0-9]*?)(&|&)download_id=([0-9]*?)(\'|")#si', 'muzika-kategorija-\1-daina-\3.html\4', $buf);
$buf = preg_replace('#downloads\.php#si', 'muzika.html', $buf);
$buf = preg_replace('#faq\.php\?cat_id=([0-9]*?)(\'|")#si', 'FAQ-kategorija-\1.html\2', $buf);
$buf = preg_replace('#faq\.php#si', 'FAQ.html', $buf);
$buf = preg_replace('#weblinks\.php\?cat_id=([0-9]*?)(\'|")#si', 'nuoroda-katalogas-\1.html\2', $buf);
$buf = preg_replace('#weblinks\.php\?cat_id=([0-9]*?)(&|&)weblink_id=([0-9]*?)(\'|")#si', 'nuoroda-katalogas-\1-strone-\3.html\4', $buf);
$buf = preg_replace('#weblinks\.php#si', 'nuoroda.html', $buf);
$buf = preg_replace('#contact\.php#si', 'kontaktai.html', $buf);
$buf = preg_replace('#photogallery\.php\?album_id=([0-9]*?)(\'|")#si', 'nuotraukos-albumas-\1.html\2', $buf);
$buf = preg_replace('#photogallery\.php\?photo_id=([0-9]*?)(\'|")#si', 'nuotraukos-foto-\1.html\2', $buf);
$buf = preg_replace('#showphoto\.php\?photo_id=([0-9]*?)(\'|")#si', 'rodyti-nuotrauka-\1.html\2', $buf);
$buf = preg_replace('#photogallery\.php#si', 'fotoalbumas.html', $buf);
$buf = preg_replace('#search\.php\?stype=f#si', 'ieskoti-forume.html', $buf);
$buf = preg_replace('#search\.php#si', 'ieskoti.html', $buf);
$buf = preg_replace('#profile\.php\?lookup=([0-9]*?)(\'|")#si', 'narys-\1.html\2', $buf);
$buf = preg_replace('#print\.php\?type=N(&|&)item_id=([0-9]*?)(\'|")#si', 'spausdinti-\2.html\3', $buf);
$buf = preg_replace('#print\.php\?type=A(&|&)item_id=([0-9]*?)(\'|")#si', 'spausdinti-stacia-\2.html\3', $buf);
$buf = preg_replace('#register\.php#si', 'registracija.html', $buf);
$buf = preg_replace('#lostpassword\.php#si', 'slaptazodis.html', $buf);
$buf = preg_replace('#ion/index\.html#si', 'ion/index.php', $buf);
}
return $buf;
}

// Start Output Buffering
ob_start("f_url");




Čia padarytas pagal muzikos weba. Galima nuorodas keisti pagal save.

Kaip viskas atrodo galit pažiūrėti čia:

http://www.tracklist.lt

Redagavo cario· 2009 Vas. 19 16:02:19