求正则表达式,有研究的进来看看.应该不难的. “硬”办法:要在APACHE的httpd.conf里配置,或者PHP文件根目录下的.htaccessRewriteEngine onRewriteRule ^([a-zA-Z]{1,})/([0-9]{1,}).html /index?$1=$2“软”办法没实际用过不记得怎么说了,楼下补上。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 \/index\?([a-z]*[a-z])[=]([0-9]*[0-9])\1/\2.htmleditplus测试通过 to: hean(河岸) 你好,我想把全站做成静态的,自己写个脚本生成html保存,没有用rewrite,所以我想用 preg_replace 函数对网页中的连接处理一下,不过也谢谢你。 to dzrior:如果用 preg_replace 进行 替换, 应该如何写? 这个 $filetxt = preg_replace('/index\?xyz=(\d+)/', 'xyz/\$1.html', $filetxt);没有成功。 $str='/index?xyz=1';echo preg_replace('#\/index\?(.*?)\=(\d+)#i','/\\1/\\2.html',$str); to:zeroleonhart(Strong Point:Algorithm)非常感谢,测试通过了。可否指点一下, # 是哪里的? 我在 php manual 的例子里没有见到。另外我又修改了原来的代码。 这样也是可以的。 echo preg_replace('/index\?xyz=(\d+)/', 'xyz/$1.html', $str); 我这里 xyz 参数名是比较固定的,所以我就直接当普通字符串处理了。 怎么在一张朋友表里面查询和自己有相同朋友并且不是自己的朋友的用户 这是什吗错误,很奇怪 mysql数据库字段不能插入数据 !$this->alias && $this->alias = $this->table; 这条语句是如何执行的? 请问这句有什么问题 在PHP中发宋邮件提出警告,大家告诉我怎么解决!,谢谢 筛选重复+翻页问题 请问怎样利用strtotime将日期格式的字符串转换为 UNIX 时间戳? 发布我的php二级联动菜单,无刷新,类别从数据库调入并散分 如何在某段时间内调用某方法 php+linux的中间层用什么封装 php或asp函数urlencode编码中文问题
\1/\2.htmleditplus测试通过
如果用 preg_replace 进行 替换, 应该如何写? 这个 $filetxt = preg_replace('/index\?xyz=(\d+)/', 'xyz/\$1.html', $filetxt);
没有成功。
echo preg_replace('#\/index\?(.*?)\=(\d+)#i','/\\1/\\2.html',$str);