Originalmente inviato da
AngelinoAnt
Ciao Evcz....tnk x il link...cmq il mod. rewrite mi serve x il mio portale :P :P.
Un altra cosa....rallenta molto il tempo di caricamento?
Ps. ho letto la pag. ma quello che c'è scritto non fa molto al caso mio....
io vorrei rendere + spider friendly il mio portale....so che si poteva fare in modo che il "?" vensse trasformato in / ed altre cose del genere....come si fa
PSS. Non puoi scrivere qui il mod. rewrite che usi tu x il nuke x esempio
Grazie x l'aiuto ;)
Bye.
ho fatto alcune prove e non rallenta nulla
ecco cosa uso io:
nell'header prima di mandare qlsiasi cosa in output ci metto questo che crea il buffer e gli array delle sostituzioni:
[code:1:428ea855eb]ob_start();
function replace_for_mod_rewrite(&$s) {
$urlin = array(
"'(?<!/)modules.php\?name=News&amp;file=article&a mp;amp;sid=([0-9]*)&amp;mode=([a-z]*)&amp;order=([0-9]*)&amp;thold=([0-9\-]*)&amp;page=([0-9]*)'",
"'(?<!/)modules.php\?name=News&amp;file=article&a mp;sid=([0-9]*)&mode=([a-z]*)&order=([0-9]*)&thold=([0-9\-]*)&page=([0-9]*)'",
"'(?<!/)modules.php\?name=News&amp;file=article&a mp;amp;sid=([0-9]*)&amp;mode=([a-z]*)&amp;order=([0-9]*)&amp;thold=([0-9\-]*)'",
"'(?<!/)modules.php\?name=News&file=article&s id=([0-9]*)&mode=([a-z]*)&order=([0-9]*)&thold=([0-9\-]*)'",
"'(?<!/)modules.php\?name=News&amp;file=article&a mp;amp;sid=([0-9]*)&amp;page=([0-9]*)'",
"'(?<!/)modules.php\?name=News&file=article&s id=([0-9]*)&page=([0-9]*)'",
"'(?<!/)modules.php\?name=News&amp;file=article&a mp;amp;sid=([0-9]*)'",
"'(?<!/)modules.php\?name=News&file=article&s id=([0-9]*)'",
"'(?<!/)modules.php\?name=News&amp;new_topic=( ;[0-9]*)'",
"'(?<!/)modules.php\?name=News&new_topic=(	 1;0-9]*)'",
"'(?<!/)modules.php\?name=Stories_Archive&sa=show _month&year=([0-9]*)&month=([0-9]*)&month_l=([a-zA-Z]*)'",
"'(?<!/)modules.php\?name=Stories_Archive'",
"'(?<!/)modules.php\?name=Downloads&d_op=getit&am p;amp;lid=([0-9]*)'",
"'(?<!/)modules.php\?name=Downloads&d_op=viewdown load&amp;cid=([0-9]*)&amp;min=([0-9]*)&amp;orderby=titleA&amp;show=& #40;[0-9]*)'",
"'(?<!/)modules.php\?name=Downloads&d_op=viewdown load&amp;cid=([0-9]*)'",
"'(?<!/)modules.php\?name=Downloads&d_op=viewdown loaddetails&amp;lid=([0-9]*)&amp;ttitle=([/:\-\'{}()._&a-zA-Z0-9+= ]*)'",
"'(?<!/)modules.php\?name=(Downloads\")' ",
"'(?<!/)modules.php\?name=Reviews&rop=showcontent &amp;id=([0-9]*)'",
"'(?<!/)modules.php\?name=Reviews&rop=write_revie w'",
"'(?<!/)modules.php\?name=Reviews&rop=postcomment &amp;id=([0-9]*)&amp;title=([a-zA-Z0-9+]*)'",
"'(?<!/)modules.php\?name=Reviews&rop=mod_review& amp;amp;id=([0-9]*)'",
"'(?<!/)modules.php\?name=Reviews&rop=del_review& amp;amp;id_del=([0-9]*)'",
"'(?<!/)modules.php\?name=Reviews&rop=(	 1;a-zA-Z0-9]*)'",
"'(?<!/)modules.php\?name=Reviews'",
"'(?<!/)modules.php\?name=Submit_News'",
//"'(?<!/)modules.php\?name=Topics'",
//"'(?<!/)modules.php\?name=Top&zx=([a-zA-Z0-9+]*)'",
//"'(?<!/)modules.php\?name=Top'",
"'(?<!/)modules.php\?name=FAQ&amp;myfaq=yes&a mp;id_cat=([0-9]*)&amp;categories=([a-zA-Z0-9+]*)'",
"'(?<!/)modules.php\?name=FAQ'",
"'(?<!/)modules.php\?name=Content&amp;pa=showpage &amp;pid=([0-9]*)'",
"'(?<!/)modules.php\?name=Content&amp;pa=list_pag es_categories&amp;cid=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewforum&a mp;f=([0-9]+)&amp;topicdays=([0-9]+)&amp;start=([0-9]+)'",
"'(?<!/)modules.php\?name=Forums&file=viewforum&a mp;f=([0-9]*)&amp;(mark|start)=(	 1;a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewforum&a mp;f=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&a mp;t=([0-9]+)&amp;start=([0-9]+)&amp;postdays=([0-9]+)&amp;postorder=asc&amp;highlig ht='",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&a mp;t=([0-9]+)&amp;postdays=([0-9]+)&amp;postorder=asc&amp;start=& #40;[0-9]+)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&a mp;t=([0-9]*)&amp;(start|view|highlight) ;=([/:\-\'(){}.&=_a-zA-Z0-9 ]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&a mp;t=([0-9]*)&amp;([a-zA-Z0-9]*)=topic&amp;start=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=viewtopic&a mp;(p|t)=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=profile& ;mode=register&amp;agreed=true&amp;coppa=& #40;[a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums&file=profile& ;mode=register&amp;agreed=([a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums&file=modcp&m ode=([a-zA-Z0-9_]*)&amp;p=([0-9_&]*)&amp;t=([a-zA-Z0-9_&=\.\;]*)'",
"'(?<!/)modules.php\?name=Forums&file=modcp&t =([0-9]*)&amp;mode=([a-zA-Z0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)&mode=([a-zA-Z0-9_]*)&amp;t=([0-9]*)&popup=([0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)&mode=([a-zA-Z0-9_]*)&(p|t|f|u|popup)=(	 1;0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)&mode=([a-zA-Z0-9_]*)&amp;(p|t|f|u|popup)=( ;[0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)&amp;mode=([a-zA-Z0-9_]*)&(p|t|f|u|popup)=(	 1;0-9]*)'",
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)&mode=([a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums&file=search& ([a-zA-Z0-9_]*)=([a-zA-Z0-9_]*)&amp;([a-zA-Z0-9_]*)=([a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)&([a-zA-Z0-9_]*)=([a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums&file=index'" ;,
"'(?<!/)modules.php\?name=Forums&file=(	 1;a-zA-Z0-9_]*)'",
"'(?<!/)modules.php\?name=Forums'",
"'(?<!/)modules.php\?name=Sections&op=(printp age|viewarticle)&artid=([0-9]*)'",
"'(?<!/)modules.php\?name=Sections&op=listarticle s&secid=([0-9]*)'",
"'(?<!/)modules.php\?name=Sections'",
"'(?<!/)modules.php\?name=Your_Account&op=userinf o&username=([a-zA-Z0-9_-]*)'",
"'(?<!/)modules.php\?name=Your_Account&amp;op=use rinfo&amp;username=([a-zA-Z0-9_-]*)'",
"'(?<!/)modules.php\?name=Web_Links&l_op=NewLinks Date&amp;selectdate=([0-9]+)'",
"'(?<!/)modules.php\?name=Web_Links&l_op=(Add Link|MostPopular|NewLinks|RandomLink|TopRated) '",
"'(?<!/)modules.php\?name=Web_Links&l_op=ratelink &amp;lid=([0-9]*)&amp;ttitle=([/:\-\'(){}.&=_a-zA-Z0-9 ]*)'",
"'(?<!/)modules.php\?name=Web_Links&l_op=visit&am p;amp;lid=([0-9]*)'",
"'(?<!/)modules.php\?name=Web_Links&l_op=viewlink &amp;cid=([0-9]*)&amp;min=([0-9]*)&amp;orderby=titleA&amp;show=& #40;[0-9]*)'",
"'(?<!/)modules.php\?name=Web_Links&l_op=viewlink &amp;cid=([0-9]*)'",
"'(?<!/)modules.php\?name=Web_Links'"
);
$urlout = array(
"article-\\1-\\2-\\3-\\4-\\5.html",
"article-\\1-\\2-\\3-\\4-\\5.html",
"article-\\1-\\2-\\3-\\4.html",
"article-\\1-\\2-\\3-\\4.html",
"article\\1-\\2.html",
"article\\1-\\2.html",
"article\\1.html",
"article\\1.html",
"article-topic-\\1.html",
"article-topic-\\1.html",
"archive-\\1-\\2-\\3.html",
"archive.html",
"downloads-file-\\1.html",
"downloads-cats-\\1-\\2-\\3.html",
"downloads-cat-\\1.html",
"downloads-file-\\1-details-\\2.html",
"downloads.html\"",
"reviews-\\1.html",
"reviews-new.html",
"reviews-comment-\\1-\\2",
"reviews-\\1-edit.html",
"reviews-\\1-delete.html",
"reviews-sortby-\\1.html",
"reviews.html",
"submit.html",
//"topics.html",
//"top-\\1.html",
//"top.html",
"faq-\\1-\\2.html",
"faq.html",
"contentid-\\1.html",
"content-cat-\\1.html",
"forumx\\1-\\2-\\3.html",
"forum\\1-\\2\\3.html",
"forum\\1.html",
"postx\\1-\\2-\\3.html",
"postxf\\1-\\2-\\3.html",
"posts\\1-\\2\\3.html",
"topic\\1-\\2-\\3.html",
"post\\1\\2.html",
"register-coppa-\\1.html",
"register-\\1.html",
"poster\\1-\\2_\\3.html",
"modcp\\1-\\2.html",
"forums-\\1-\\2-\\3-\\4.html",
"forums-\\1-\\2-\\3-\\4.html",
"forums-\\1-\\2-\\3-\\4.html",
"forums-\\1-\\2-\\3-\\4.html",
"forums-\\1-\\2.html",
"forum\\1-\\2-\\3-\\4.html",
"forums\\1-\\2-\\3.html",
"forums.html",
"forum-\\1.html",
"forums.html",
"section-\\1-\\2.html",
"section-\\1.html",
"sections.html",
"userinfo-\\1.html",
"userinfo-\\1.html",
"linksnew-\\1.html",
"linkop-\\1.html",
"ratelink-\\1-\\2.html",
"viewlink-\\1.html",
"links-\\1-\\2-\\3.html",
"link-\\1.html",
"links.html"
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}[/code:1:428ea855eb]
nel footer dopo aver stampato tutto ci metto questo che prende il buffer, rikiama la funz per la sostituzione e manda in output:
[code:1:428ea855eb]$contents = ob_get_contents();
ob_end_clean();
echo replace_for_mod_rewrite($contents);
[/code:1:428ea855eb]
quindi questo è il contenuto dell'.htaccess
[code:1:428ea855eb]
RewriteEngine on
#Articles
RewriteRule ^article-([0-9]*)-([a-z]*)-([0-9]*)-([0-9\-]*)-([0-9]*).html modules.php?name=News&file=article&sid=$1& amp;mode=$2order=$3&thold=$4&page=$5
RewriteRule ^article-([0-9]*)-([a-z]*)-([0-9]*)-([0-9]*).html modules.php?name=News&file=article&sid=$1& amp;mode=$2order=$3&thold=$4&page=$5
RewriteRule ^article([1-9][0-9]*)-([0-9]*).* modules.php?name=News&file=article&sid=$1& amp;page=$2
RewriteRule ^article([1-9][0-9]*).* modules.php?name=News&file=article&sid=$1
RewriteRule ^article-topic-([0-9]*).html modules.php?name=News&new_topic=$1
RewriteRule ^allnews.html modules.php?name=News&file=allindex
#Content
RewriteRule ^contentid-([1-9][0-9]*).html modules.php?name=Content&pa=showpage&cid=$ 1
RewriteRule ^content-cat-([1-9][0-9]*).html modules.php?name=Content&pa=list_pages_categor ies&cid=$1
#FAQ
RewriteRule ^faq.html modules.php?name=FAQ
RewriteRule ^faq-([0-9]*)-([a-zA-Z0-9+]*).html modules.php?name=FAQ&myfaq=yes&id_cat=$1&a mp;categories=$2
#Forums
RewriteRule ^forumx([0-9]+)-([0-9]+)-([0-9]+).html modules.php?name=Forums&file=viewforum&f=$ 1&topicdays=$2&start=$3
RewriteRule ^forum([1-9][0-9]*)-(mark|start)([a-zA-Z0-9_]*).html modules.php?name=Forums&file=viewforum&f=$ 1&$2=$3
RewriteRule ^forum([1-9][0-9]*).* modules.php?name=Forums&file=viewforum&f=$ 1
RewriteRule ^postx([0-9]+)-([0-9]+)-([0-9]+).html modules.php?name=Forums&file=viewtopic&t=$ 1&start=$2&postdays=$3&postorder=asc&a mp;highlight=
RewriteRule ^postxf([0-9]+)-([0-9]+)-([0-9]+).html modules.php?name=Forums&file=viewtopic&t=$ 1&postdays=$2&postorder=asc&start=$3
RewriteRule ^posts([0-9]*)-(start|view|highlight)([[: punct:]/:\-\'(){}.&=_a-zA-Z0-9\ ]*).html modules.php?name=Forums&file=viewtopic&t=$ 1&$2=$3
RewriteRule ^topic([1-9][0-9]*)-([a-zA-Z0-9]*)-([0-9]*).html modules.php?name=Forums&file=viewtopic&t=$ 1&$2=topic&start=$3
RewriteRule ^post(p|t)([1-9][0-9]*).* modules.php?name=Forums&file=viewtopic&$1= $2
RewriteRule ^register-coppa-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=profile&mode= register&agreed=true&coppa=$1
RewriteRule ^register-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=profile&mode= register&agreed=$1
RewriteRule ^poster([a-zA-Z0-9_]*)-([0-9_&]*)_([a-zA-Z0-9_&=[:punct:]\.\;]*).h tml modules.php?name=Forums&file=modcp&mode=$1 &p=$2&t=$3
RewriteRule ^modcp([0-9]*)-([a-zA-Z0-9]*).html modules.php?name=Forums&file=modcp&t=$1&am p;mode=$2
RewriteRule ^forums-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([0-9]*)-([1-9][0-9]*).html modules.php?name=Forums&file=$1&mode=$2&am p;t=$3&popup=$4
RewriteRule ^forums-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-(p|t|f|u|popup)-([0-9]*).html modules.php?name=Forums&file=$1&mode=$2&am p;$3=$4
RewriteRule ^forums-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=$1&mode=$2
RewriteRule ^forum([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=search&$1=$2& amp;$3=$4
RewriteRule ^forums([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=$1&$2=$3
RewriteRule ^forums.html modules.php?name=Forums&file=index
RewriteRule ^forum-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=$1
RewriteRule ^forums.html modules.php?name=Forums
#Downloads
RewriteRule ^downloads.html modules.php?name=Downloads
RewriteRule ^downloads-cat-([0-9]*).htmlorderby=([a-zA-Z_]*) modules.php?name=Downloads&d_op=viewdownload&a mp;cid=$1("derby=$2
RewriteRule ^downloads-cats-([0-9]*)-([0-9]*)-([0-9]*).html modules.php?name=Downloads&d_op=viewdownload&a mp;cid=$1&min=$2("derby=titleA&sh ow=$3
RewriteRule ^downloads-cat-([0-9]*).html modules.php?name=Downloads&d_op=viewdownload&a mp;cid=$1
RewriteRule ^downloads-file-([0-9]*)-details-([[:punct:]/:\-\'{}()._&a-zA-Z0-9+=]*).html modules.php?name=Downloads&d_op=viewdownloadde tails&lid=$1&ttitle=$2
RewriteRule ^downloads-file-([0-9]*).html modules.php?name=Downloads&d_op=getit&lid= $1
#Stories Archive
RewriteRule ^archive.html modules.php?name=Stories_Archive
RewriteRule ^archive-([0-9]*)-([0-9]*)-([a-zA-Z]*).* modules.php?name=Stories_Archive&sa=show_month &year=$1&month=$2&month_l=$3
#Reviews
RewriteRule ^reviews.html modules.php?name=Reviews
RewriteRule ^reviews-([0-9]*).html modules.php?name=Reviews&rop=showcontent&i d=$1
RewriteRule ^reviews-new.html modules.php?name=Reviews&rop=write_review
RewriteRule ^reviews-sortby-([a-zA-Z0-9]*).html modules.php?name=Reviews&rop=$1
RewriteRule ^reviews-comment-([0-9]*)-([[:punct:]a-zA-Z0-9]*).* modules.php?name=Reviews&rop=postcomment&i d=$1&title=$2
RewriteRule ^reviews-([0-9]*)-delete.html modules.php?name=Reviews&rop=del_review&id _del=$1
RewriteRule ^reviews-([0-9]*)-edit.html modules.php?name=Reviews&rop=mod_review&id =$1
#Sections
RewriteRule ^section-(printpage|viewarticle)-([0-9]*).html modules.php?name=Sections&op=$1&artid=$2
RewriteRule ^section-([0-9]*).html modules.php?name=Sections&op=listarticles& secid=$1
RewriteRule ^sections.html modules.php?name=Sections
#Surveys
RewriteRule ^surveys.html modules.php?name=Surveys
RewriteRule ^survey([a-zA-Z0-9]*)results.html modules.php?name=Surveys&op=results&pollID =$1
RewriteRule ^survey([a-zA-Z0-9]*).html modules.php?name=Surveys&pollID=$1
#Submit
RewriteRule ^submit.html modules.php?name=Submit_News
#Search
#RewriteRule ^search.html modules.php?name=Search
#Top10
RewriteRule ^top-([[:print:]]*).htm l modules.php?name=Top&zx=$1
RewriteRule ^top.html modules.php?name=Top
#Topics
RewriteRule ^topics.html modules.php?name=Topics
#Your Account
RewriteRule ^userinfo-([a-zA-Z0-9_-]*).html modules.php?name=Your_Account&op=userinfo& username=$1
#WebLinks
RewriteRule ^linksnew-([0-9]+).html modules.php?op=modload&name=Web_Links&file =index&l_op=NewLinksDate&selectdate=$1
RewriteRule ^linkop-(AddLink|MostPopular|NewLinks|RandomLink|TopRa ted).html modules.php?op=modload&name=Web_Links&file =index&l_op=$1
RewriteRule ^ratelink-([0-9]*)-([[:punct:]/:\-\'(){}.&=_a-zA-Z0-9\ ]*).html modules.php?op=modload&name=Web_Links&file =index&l_op=ratelink&lid=$1&ttitle=$2
RewriteRule ^viewlink-([0-9]*).html modules.php?name=Web_Links&l_op=visit&lid= $1
RewriteRule ^links-([0-9]*)-([0-9]*)-([0-9]*).html modules.php?name=Web_Links&file=index&l_op =viewlink&cid=$1&min=$2("derby=ti tleA&show=$3
RewriteRule ^link-([0-9]*).html modules.php?name=Web_Links&l_op=viewlink&c id=$1
RewriteRule ^links.html modules.php?name=Web_Links[/code:1:428ea855eb]
puoi modificarlo in base alla struttura delle tue pag... si basa sulle espressioni regolari del perl/php
per quanto riguarda il sostiuire i ? con delle / non te lo consiglio... quando ci metti la / il browser crede che tu sia in un'altra cartella e quindi cerca le immagini o i link relativi nel posto sbagliato
There are three kinds of people in this world: people who watch things happen ... people who complain about things that happen ... and people who make things happen...