.htaccess 如何在htaccess中添加分页

egdjgwm8  于 2023-05-18  发布在  其他
关注(0)|答案(2)|浏览(218)

你好,我正在寻找添加分页与htaccess我有htaccess文件重写我的php网址从mysite.com/category.php?uid=123-slug-nametomysite.com/category/123-slug-name但我想添加这样的分页

> mysite.com/category/123-slub-name/page/1 
> mysite.com/category/123-slub-name/page/2
> mysite.com/category/123-slub-name/page/last etc

但我不知 prop 体如何做到这一点这里是我的htaccess文件代码

RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9-/]+)$ category.php?id=$1
RewriteRule ^category/([a-zA-Z0-9-/]+)/$ category.php?id=$1
RewriteRule ^([a-zA-Z0-9-/]+)$ article.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ article.php?url=$1
bhmjp9jg

bhmjp9jg1#

您可以用途:

RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9-/]+)/page/(.+)/?$ category.php?id=$1&page=$2 [NC,L]
RewriteRule ^category/([a-zA-Z0-9-/]+)/?$ category.php?id=$1 [L]
RewriteRule ^([a-zA-Z0-9-/]+)/?$ article.php?url=$1
knsnq2tg

knsnq2tg2#

这是我的例子。
我有更多的网站和网站有更多的网页。每个页面都有一个所有者。但是首先,我把所有的http请求重定向到https

RewriteEngine On

RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d

# From GET to Pretty
RewriteCond %{THE_REQUEST} /?sitename=([^\s&]+)&page=([^\s&]+) [NC]
RewriteRule ^ /%1/page-%2? [R=301,L,NE]

# From GET to Pretty
RewriteCond %{THE_REQUEST} /?sitename=([^\s&]+)&owner=([^\s&]+) [NC]
RewriteRule ^ /%1/owner-%2? [R=301,L,NE]

# From GET to Pretty
RewriteCond %{THE_REQUEST} /?sitename=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]

# Pretty req index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]

RewriteRule ^([^/.]*)$ /index.php?sitename=$1 [NC,L]
RewriteRule ^([^/.]*)/page-([^/.]*)$ /index.php?sitename=$1&page=$2 [NC,L,QSA]
RewriteRule ^([^/.]*)/owner-([^/.]*)$ /index.php?sitename=$1&owner=$2 [NC,L,QSA]

相关问题