本文介绍了URL使用的.htaccess和Apache两个参数重写)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的.htaccess code:

I have below code in .htaccess:

Options -Indexes

RewriteEngine on

RewriteRule ^category/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ themes/tema_2/category.php?slug=$1&page=$2 [NC,L,QSA]

我有问题,第二个参数页......当我做 $ _ GET ['塞'] 我得到了这样的事情: fudbal /页/ 2 如果我的网址是这样的: http://exmpl.com/category/fudbal/page/2

I have problem with second parameter "page"... When I do $_GET['slug'] i got something like this: fudbal/page/2 if my url is like this: http://exmpl.com/category/fudbal/page/2.

所以 $ _ GET ['塞'] 返回所有在类别/ 像它的蛞蝓。

So $_GET['slug'] returns all after category/ like it's slug.

我要做到这一点:当我回声 $ _ GET ['塞'] 来呼应 fudbal 键,当我赞同 $ _ GET ['页'] 来呼应 2

I need to achieve this: When I echo $_GET['slug'] to echo fudbal and When I echo $_GET['page'] to echo 2.

推荐答案

您需要调整您的正则表达式来解决这样您的问题:

You need to tweak your regex to fix your issue like this:

Options -Indexes
RewriteEngine on

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

这篇关于URL使用的.htaccess和Apache两个参数重写)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 21:16