2011-12-22 35 views
7

我有一个出租物业网站,我正在迁移到一个新的网站。我有来自Apache的规则问题。我的htaccess规则转到页面,而不是id

如: /FL /迈阿密/ 2/ /CA /圣迭/ 41/

我希望能够根据网址来动态显示页面

rewriterule ^([a-z]+)/$ index.php?state=$1&city=&mode=list 
rewriterule ^([a-z]+)/([a-z]+)/$ index.php?state=$1&city=$2&mode=list 
rewriterule ^([a-z]+)/([a-z]+)/([0-9]+)/$ index.php?state=$1&city=$2&id=$3 

所以我看到所有的列表中为每个国家或列表中为每个国家/城市

我现在的问题是,当我尝试看看第二页,我得到的ID,而不是

我有没有一种方法可以解决这个问题?

回答

8

这里有什么工作适合你(把这个在你的.htaccess你的文档根):

RewriteEngine On 
RewriteBase/

rewriterule ^([a-z]+)/?$ index.php?state=$1&city=&mode=list [NC,L,QSA] 
rewriterule ^([a-z]+)/([a-z0-9_\-]+)/?$ index.php?state=$1&city=$2&mode=list [NC,L,QSA] 
rewriterule ^([a-z]+)/([a-z0-9_\-]+)/([0-9]+)/?$ index.php?state=$1&city=$2&pagenum=$3&mode=page [NC,L,QSA] 
rewriterule ^([a-z]+)/([a-z0-9_\-]+)/([0-9]+)/([a-z0-9_\-]+)/?$ index.php?state=$1&city=$2&id=$3&mode=view [NC,L,QSA] 

所以:

/california/san-diego/2/california/san-diego/2/意愿去第2页

/FL/Miami/2/home-house-test/FL/Miami/2/home-house-test/会去财产页面

+0

非常感谢你 – 2011-12-22 02:41:29

+0

你是非常欢迎的 – 2011-12-22 02:44:55