function replace_for_mod_rewrite(&$s)
{
$in = array("'(?<!/)modules.php\?op=modload&name=News&file=article&sid=([0-9]*)&mode=([a-zA-Z]*)&order=([0-9]*)&thold=([0-9]*)'",
"'(?<!/)modules.php\?op=modload&name=News&file=index&catid=&topic=([1-9][0-9]*)&allstories=1'",
"'(?<!/)modules.php\?op=modload&name=News&file=index&catid=&topic=([1-9][0-9]*)'",
"'(?<!/)modules.php\?op=modload&name=Sections&file=index&req=listarticles&secid=([1-9][0-9]*)'",
"'(?<!/)modules.php\?op=modload&name=Sections&file=index&req=viewarticle&artid=([1-9][0-9]*)&page=([1-9][0-9]*)'",
"'(?<!/)modules.php\?op=modload&name=Sections&file=index&req=printpage&artid=([1-9][0-9]*)'",
"'(?<!/)modules.php\?op=modload&name=NS-Polls&file=index&req=results&pollID=([0-9]*)&mode=thread&order=0&thold=0'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=index&([a-zA-Z0-9_.;+&]*)=([a-zA-Z0-9_.;+&]*)&([a-zA-Z0-9_.;+&]*)=([a-zA-Z0-9_.;+&]*)&([a-zA-Z0-9_.;+&]*)=([a-zA-Z0-9_.;+&\[\] ]*)&([a-zA-Z0-9_.;+&\[\] ]*)=([a-zA-Z0-9_.;+&\[\] ]*)'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=index&([a-zA-Z0-9_.&]*)=([a-zA-Z0-9_.&]*)&([a-zA-Z0-9_.&]*)=([a-zA-Z0-9_.&]*)&([a-zA-Z0-9_.&]*)=([a-zA-Z0-9_.&\[\] ]*)&([a-zA-Z0-9_.&\[\] ]*)=([a-zA-Z0-9_.&\[\] ]*)'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=index&([a-zA-Z0-9]*)=([a-zA-Z0-9]*)&([a-zA-Z0-9_.;+&]*)=([a-zA-Z0-9_.;+&]*)&([a-zA-Z0-9_.;+&]*)=([a-zA-Z0-9_.;&+]*)'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=index&([a-zA-Z0-9]*)=([a-zA-Z0-9]*)&([a-zA-Z0-9]*)=([a-zA-Z0-9]*)'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=index&([a-zA-Z0-9&]*)=([a-zA-Z0-9&]*)'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=index'",
"'(?<!/)modules.php\?op=modload&name=([^&]*)&file=([a-zA-Z0-9]*)'",
"'(?<!/)print.php\?sid=([0-9]*)'"
);
$out = array("article\\1.html",
"Topic\\1-all.html",
"Topic\\1.html",
"Sections\\1.html",
"Sections-article\\1-page\\2.html",
"Sections-print-article\\1.html",
"NS-Polls-results-\\1.html",
"\\1-\\2-\\3-\\4-\\5-\\6-\\7-\\8-\\9-\10-\11.html",
"\\1-\\2-\\3-\\4-\\5-\\6-\\7-\\8-\\9.html",
"\\1-\\2-\\3-\\4-\\5-\\6-\\7.html",
"\\1-\\2-\\3-\\4-\\5.html",
"\\1-\\2-\\3.html",
"\\1.html",
"\\1-\\2.html",
"print\\1.html"
);
$s = preg_replace($in, $out, $s);
return $s;
}
"'(?<!/)modules.php\?op=modload&name=News&file=article&sid=([0-9]*)&mode=([a-zA-Z]*)&order=([0-9]*)&thold=([0-9]*)'"
&(and not just &). The new API strictly follows and supports this already, but if you still find links in your site that aren't converted properly, it is most likely because old modules have used just &.
RewriteEngine On
#Articles
RewriteRule ^article([1-9][0-9]*).* modules.php?op=modload&name=News&file=article&sid=$1
#Topics
RewriteRule ^Topic([1-9][0-9]*)-all.* modules.php?op=modload&name=News&file=index&catid=&topic=$1&allstories=1
RewriteRule ^Topic([1-9][0-9]*).* modules.php?op=modload&name=News&file=index&catid=&topic=$1
#FAQ
RewriteRule ^FAQ([1-9][0-9]*)-([0-9]*).* modules.php?op=modload&name=FAQ&file=index&myfaq=yes&id_cat=$1
#Sections
RewriteRule ^Sections([1-9][0-9]*).* modules.php?op=modload&name=Sections&file=index&req=listarticles&secid=$1
RewriteRule ^Sections-article([1-9][0-9]*)-page([1-9][0-9]*).* modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=$1&page=$2
RewriteRule ^Sections-print-article([1-9][0-9]*).* modules.php?op=modload&name=Sections&file=index&req=printpage&artid=$1
#NS-type modules
RewriteRule ^NS-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).* modules.php?op=modload&name=NS-$1&file=index&$2=$3&$4=$5
RewriteRule ^NS-Polls-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?op=modload&name=NS-Polls&file=index&req=$1&pollID=$2
RewriteRule ^NS-Polls-([a-zA-Z0-9_]*).html modules.php?op=modload&name=NS-Polls&file=index&pollID=$1
RewriteRule ^NS-([a-zA-Z0-9_]*).html modules.php?op=modload&name=NS-$1&file=index
#General Stuff
RewriteRule ^([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).* modules.php?op=modload&name=$1&file=index&$2=$3&$4=$5&$6=$7&$8=$9
RewriteRule ^([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).* modules.php?op=modload&name=$1&file=index&$2=$3&$4=$5&$6=$7
RewriteRule ^([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).* modules.php?op=modload&name=$1&file=index&$2=$3&$4=$5
RewriteRule ^([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).* modules.php?op=modload&name=$1&file=index&$2=$3
RewriteRule ^([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?op=modload&name=$1&file=$2
RewriteRule ^([a-zA-Z0-9_]*).html modules.php?op=modload&name=$1&file=index