0
我想這些URL轉換爲搜索引擎友好的URL:正則表達式是需要改變URL
index.php?t=1&s=1&offset=50&hits=50 ---> index-t-1-s-1-offset-50-hits-50.html
index.php?t=1&s=1 ---> index-t-1-s-1.html
index.php?t=1&s=&offset=50&hits=50 ---> index-t-1-s-1-offset-50-hits-50.html
index.php?t=1 ---> index-t-1.html
我寫了這個:
$filename = substr(basename($base_href),0,'-4');
$str = preg_replace('/href=\'\?t=(\d+)&s=(\d+)\'/i', 'href=\''.$filename.'-t-$1-s-$2.html\'', $str);
,但我需要一個通用的表達。你能幫我嗎?
看看這裏:http://codepad.org/8JIsK1J0 –