普通防爆pression对于URL查询 [英] Regular Expression For URL Query

查看:129
本文介绍了普通防爆pression对于URL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用mod_rewrite在我的htaccess的文件重写我的网址,我已经在做分页的时候遇到了问题。

I've been using mod_rewrite in my htaccess file to rewrite my urls and I've run into a problem when doing pagination.

下面的网址为我的网页: http://domain.com/concerts/features/folk-roots?page=2

Here's the url for my page: http://domain.com/concerts/features/folk-roots?page=2

htaccess文件:

htaccess file:

RewriteRule ^features/([^/]*)?page=([0-9]*)$ featureCat.php?cat=$1&page=$2 [NC,L]

它工作正常,没有网页查询,但如果我想改变我的网页无法弄清楚如何写正规的前pression抓取页面#。

It works fine without the page query, but if I want to change pages I can't figure out how to write the regular expression to grab the page #.

任何想法,将AP preciated!

Any ideas would be appreciated!

推荐答案

您需要立即重写规则之前,使用的RewriteCond来获得访问查询字符串:

You need to use RewriteCond immediately before the RewriteRule to get access to the query string:

RewriteCond %{QUERY_STRING} ^page=([0-9]*)$
RewriteRule ^features/([^/]*)$ featureCat.php?cat=$1&page=%1 [NC,L]

这篇关于普通防爆pression对于URL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆