UCHome 开启 URL REWRITE 后,默认的后缀是 html ,您还可以根据自己的喜好修改为其他后缀,下面请看详细修改方法:
例如:修改后缀 html 为 shtml,可以按照以下步骤:
1、修改rewrite规则:
找到:
RewriteRule ^/(space|network)\-(.+)\.html$ /$1.php?rewrite=$2 [L]
RewriteRule ^/(space|network)\.html$ /$1.php [L]
改为
RewriteRule ^/(space|network)\-(.+)\.shtml$ /$1.php?rewrite=$2 [L]
RewriteRule ^/(space|network)\.shtml$ /$1.php [L]
2、修改 source\function_common.php 文件
找到:
function ob_out() {
global $_SGLOBAL, $_SCONFIG;
$content = ob_get_contents();
$preg_searchs = $preg_replaces = $str_searchs = $str_replaces = array();
if($_SCONFIG['allowrewrite']) {
$preg_searchs[] = "/\<a href\=\"space\.php\?(uid|do)+\=([a-z0-9\=\&]+?)\"/ie";
$preg_searchs[] = "/\<a href\=\"space.php\"/i";
$preg_searchs[] = "/\<a href\=\"network\.php\?ac\=([a-z0-9\=\&]+?)\"/ie";
$preg_searchs[] = "/\<a href\=\"network.php\"/i";
$preg_replaces[] = 'rewrite_url(\'space-\',\'\\2\')';
$preg_replaces[] = '<a href="space.html"';
$preg_replaces[] = 'rewrite_url(\'network-\',\'\\1\')';
$preg_replaces[] = '<a href="network.html"';
}
if($_SCONFIG['linkguide']) {
$preg_searchs[] = "/\<a href\=\"http\:\/\/(.+?)\"/ie";
$preg_replaces[] = 'iframe_url(\'\\1\')';
}
if($_SGLOBAL['inajax']) {
$preg_searchs[] = "/([\x01-\x09\x0b-\x0c\x0e-\x1f])+/";
$preg_replaces[] = ' ';
$str_searchs[] = ']]>';
$str_replaces[] = ']]>';
}
if($preg_searchs) {
$content = preg_replace($preg_searchs, $preg_replaces, $content);
}
if($str_searchs) {
$content = trim(str_replace($str_searchs, $str_replaces, $content));
}
obclean();
echo $content;
if($_SGLOBAL['inajax']) {
echo "]]></root>";
exit();
} elseif(D_BUG) {
@include_once(S_ROOT.'./source/inc_debug.php');
}
}
//rewrite链接
function rewrite_url($pre, $para) {
$para = str_replace(array('&','='), array('-', '-'), $para);
return '<a href="'.$pre.$para.'.html"';
}
修改上面两个方法中的 html 为 shtml 即可。
UCenter Home 开启Rewrite的方法,可以参考:
Apache:
http://u.discuz.net/help/index.php?view=%5B3%5D%20UCenter%20Home%20%C6%F4%D3%C3Rewrite%B7%FE%CE%F1%C6%F7%C5%E4%D6%C3%CB%B5%C3%F7
IIS:
https://discuz.dismall.com/viewthread.php?tid=903180&highlight=rewrite |