htaccess重写分页规则不起作用

时间:2014-07-30 06:51:39

标签: apache .htaccess mod-rewrite pagination

我的htaccess中有以下内容:

Options +FollowSymLinks -Multiviews -Indexes 
DirectoryIndex index.php

RewriteEngine On
RewriteBase /

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]

现在,我正在尝试添加一些分页规则,这些规则将我的htaccess文件保留如下:

Options +FollowSymLinks -Multiviews -Indexes 
DirectoryIndex index.php

RewriteEngine On
RewriteBase /

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]

RewriteRule ^beta/network/showcase/category/(.*)/page/(.*)$ beta/network/showcase.php?category=$1&page=$2 [L]
RewriteRule ^beta/network/showcase/category/(.*)$ beta/network/showcase.php?category=$1 [L]
RewriteRule ^beta/network/showcase/page/(.*)$ beta/network/showcase.php?page=$1 [L]
RewriteRule ^beta/network/showcase/([0-9]+)$ beta/network/showcase_single.php?id=$1 [L]

除非从这一点开始,否则它们都有效:

RewriteRule ^beta/network/showcase/category/(.*)/page/(.*)$ beta/network/showcase.php?category=$1&page=$2 [L]

如果未找到页面,则会引发404错误:

  

在此服务器上找不到请求的网址/ beta / network / showcase / arts-entertainment / page /。

为什么特定规则失败?

谢谢!

1 个答案:

答案 0 :(得分:0)

根据@anubhava回复解决了问题,我忽略了网址中的'/ category /'。