htaccess rewrite rules for pagination not working

痴心易碎 提交于 2019-12-12 04:13:25

问题


I have the following in my 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]

Now, I am trying to add some pagination rules which left my htaccess file as follows:

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]

They all work unless from this one:

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

Which throws a 404 error as page not found:

The requested URL /beta/network/showcase/arts-entertainment/page/2 was not found on this server.

Why is that particular rule failing?

Thanks!


回答1:


Issue was resolved per @anubhava response, I overlooked the '/category/' in the URL.



来源:https://stackoverflow.com/questions/25030419/htaccess-rewrite-rules-for-pagination-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!