无法找出带有2个参数的mod_rewrite [英] Can't figure out mod_rewrite with 2 parameters

查看:67
本文介绍了无法找出带有2个参数的mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP构建网站并尝试制作RewriteRules.

I'm building a website with PHP and trying to make RewriteRules.

有一个类别页面,并且具有分页. 最初,URL就像

There is a category page and it has a pagination. Originally, the URL is like

/blog/category.php?category=2&page=2

我想将其重定向为/blog/category/2/page/2

我该如何进行这项工作?

How can I make this work?

仅对于类别部分,我将规则尝试为

Only for category part, I tried the rules as

RewriteRule ^category/(\d+)$ category.php?category=$1 [NC,L]

但是我不知道如何重定向页面部分.

but I couldn't figure out how to redirect the page part.

请帮助我.

推荐答案

为什么不使用缺少的page参数扩展重写规则?然后,您可以访问该页面.还有更多的可能性,但我认为在您的情况下,这是最简单的方法.

Why you don't expand your rewrite rule with the missing page parameter? Then you can access the page. There are a lot more possibilities but i think in your case it's the easiest way.

RewriteRule ^/blog/category/(\d+)/page/(\d+)$ category.php?category=$1&page=$2 [NC,L]

如果您的网址包含/blog,则应检查重写规则中是否需要它.

And if you url includes /blog you should check if you need it in your rewrite rule.

这篇关于无法找出带有2个参数的mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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