针对不同的页面htaccess的同重写规则不工作 [英] htaccess same rewrite rules for different pages not working
本文介绍了针对不同的页面htaccess的同重写规则不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的网站两个不同的页面,我需要URL重写了这两个页面。我已经试过这code,但不工作只有一个是工作的另一个不工作。
I have two different pages in my site, i need url rewriting for these two pages. I have tried this code but not working only one is working another not working.
在我的htaccess
In my htaccess
第一条规则:
RewriteRule ^([a-zA-Z0-9-/]+)$ view.php?link=$1
第二条规则:
RewriteRule ^([a-zA-Z0-9-/]+)$ list.php?name=$1
只有第一个工作,任何一个可以告诉我怎么解决这个问题。
Only first one working, can any one tell me how to solve this.
推荐答案
您需要能够在两种类型的URL来区分。鉴于这种
You need to be able to differentiate between the two types of URLs. Given this:
http://example.com/foo
是否转到 /view.php?link=foo
?或者它转到 /list.php?name=foo
?
您可以做到这一点的方法之一是preFIX的东西网址,例如动态部分:
One way you can do this is prefix the dynamic part of the URL with something, like:
http://example.com/view/foo
http://example.com/list/foo
所以,该规则将如下所示:
So the rule would look like:
RewriteRule ^view/([a-zA-Z0-9-/]+)$ view.php?link=$1
RewriteRule ^list/([a-zA-Z0-9-/]+)$ list.php?name=$1
这篇关于针对不同的页面htaccess的同重写规则不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文