Php htaccess重写问题

Php htaccess重写问题,php,.htaccess,Php,.htaccess,在网站上工作,并且在.htaccess方面遇到一些问题 我有一个分类链接,如下所示: sharing/index.php?cf=category&id=$1 sharing/cat-1?next=1 sharing/cat-1/page/1 sharing/cat-1/page/1 我把它改写成: sharing/cat-([^/]+)$ 这非常有效,然后我在脚本中添加了分页,链接中的分页如下: sharing/index.php?cf=category&id=$1

在网站上工作,并且在
.htaccess
方面遇到一些问题

我有一个分类链接,如下所示:

sharing/index.php?cf=category&id=$1
sharing/cat-1?next=1
sharing/cat-1/page/1
sharing/cat-1/page/1
我把它改写成:

sharing/cat-([^/]+)$  
这非常有效,然后我在脚本中添加了分页,链接中的分页如下:

sharing/index.php?cf=category&id=$1
sharing/cat-1?next=1
sharing/cat-1/page/1
sharing/cat-1/page/1
我想这样做:

sharing/index.php?cf=category&id=$1
sharing/cat-1?next=1
sharing/cat-1/page/1
sharing/cat-1/page/1

我已经尽力了,但没有成功。请注意,
cat-1
用于类别ID,这意味着在另一个类别中,它可能是
cat-3

尝试以下示例,其中我传递了两个变量:

RewriteRule ^player/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ players/view.php?player=$1&page=$2 [NC,L]

要扩展它,只需将([A-Za-z0-9-]+)/添加到URL,并在另一侧传递另一个参数。

错误来自未跳过正斜杠的事实

所以你应该试试这个来重写规则

RewriteRule ^sharing\/cat-([^\/]+)\/page\/([0-9]*)$ sharing/index.php?cf=category&id=$1&next=$2
分页的链接应该是这样的:

sharing/index.php?cf=category&id=$1
sharing/cat-1?next=1
sharing/cat-1/page/1
sharing/cat-1/page/1
不是您提到的(
共享/cat-1?next=1


请记住,如果您的类别仅为数字,则最好通过
([0-9]*)

更改
([^\/]+)
,,

向我们展示您尝试过的内容,以便我们可以帮助您解决此问题。您也必须更改链接。让它成为“共享/cat-1/page/1”我很抱歉,我犯了一个错误,现在很好,谢谢,我很感激