首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

url重写的有关问题,求写一条重写规则

2012-10-06 
url重写的问题,求写一条重写规则RewriteRule (.*)-(.*)_(.*).html$ $1.php?$2$3因为使用“/”会出现相对路

url重写的问题,求写一条重写规则
RewriteRule (.*)-(.*)_(.*).html$ $1.php?$2=$3

因为使用“/”会出现相对路径出错,不得已用-替代,大致意思就是
输入 article/type_2/id_3.html 跳转到 article.php?type=2&id=3
但有些页面只需要id 不要type 例如article/type_2.html 跳转到 article.php?type=2

不知道在把这两种情况综合起来后如何获取参数

如:RewriteRule (.*)[-(.*)_(.*)]*.html$ 怎么得到[]中的数据呢

了解的不深,说的可能比较啰嗦,体谅一下

[解决办法]
你原来的那个不起作用吧,你使用了?
试试这一个

XML code
RewriteRule ([a-z]+)/type_([0-9]+).html$ $1.php?type=$2 [QSA,L]RewriteRule ([a-z]+)/type_([0-9]+)/id_([0-9]+).html$ $1.php?$2=$3 [QSA,L] 

热点排行