比如:http://localhost/index.php?q=main/index&cid=1&tid=2
重写为 http://localhost/index.php/q/main-index/cid/1/tid/2
这样可以吗?或者是有什么更好的建议吗?请高手指教,小弟是才开始学习PHP,谢谢大家了
重写为 http://localhost/index.php/q/main-index/cid/1/tid/2
这样可以吗?或者是有什么更好的建议吗?请高手指教,小弟是才开始学习PHP,谢谢大家了
解决方案 »
- 警告,页面已过期,这个大家是怎么解决的?
- 新人! 给while循环弄的吐血了。哪位高手帮我虚拟出循环运行机制呀。
- 不显示删除回复显示所有回复显示星级回复显示得分回复 怎样设定iis执行时间 我上传文件到网站,五分钟就断了
- linux中,定时执行文件有问题,在线等
- 求一条sql语句里的写法,在线等!!!!!
- 本人PHP中一菜鸟往向大侠请教GD库的问题
- 关于PHP如何连接SYBASE
- 不知道那里错了,愿意帮忙看看的请进,几句话。
- 哪里有关于开发论坛或者聊天室的详细说明过程?
- php链接mysql数据库报错,PDO错误,php could not find driver
- include包含文件里,标签不解析,哪位哥哥姐姐给帮帮忙,在线等待中。。。
- 几个关于php符号 & 的问题
也可以使用PHP本身去实现。写一段PHP程序就可以了。
<?php
$queryString=$_SERVER['QUERY_STRING'];
$queryArray=explode('/');
foreach($queryArray as $val){
$tempQueryArray=explode('-',$val);
$_GET[$tempQueryArray[0]]=$tempQueryArray[1];
}
?>
这样的话应该就可以了,我临时写的,可能有错,楼主自己调试一下。
重写前:http://<servername>/index.php?a=1&b=2
重写后:http://<servername>/index.php/a-1/b-2
第二行代码:$queryArray=explode('/',$queryString);
$sURL = 'http://localhost/index.php?q=main/index&cid=1&tid=2';
$sBeforeQuery = substr($sURL, 0, stripos($sURL, '?'));
$sAfterQuery = substr($sURL, stripos($sURL, '?'));
$sAfterQuery = str_ireplace('/', '-', $sAfterQuery);
$sAfterQuery = str_ireplace(array('?', '=', '&'), array('/', '/', '/'), $sAfterQuery);
$sURL = $sBeforeQuery . $sAfterQuery;
echo $sURL;
另一种是自己定义url规则,然后按照自己的规则解析url。
iis的和apache的差不多
这URL就是框架的默认URL了