获得价值与日历和分页的hta​​ccess(get value with calendar and

2019-10-20 00:14发布

我想用增加对htaccess的分页这样。 所以我把例子。 底部有我的htaccess代码。 所以如何解决它喜欢这个。 帮我这个职位。 谢谢。

example.com/calendar/2014/page/2 < - example.com/calendar/load.php?year=2014&page=2

example.com/calendar/2014/4/page/2 < - example.com/calendar/load.php?year=2014&month=4&page=2

example.com/calendar/2014/4/27/page/2 < - example.com/calendar/load.php?year=2014&month=4&date=27&page=2

在这里,我的htaccess代码

/calendar/.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /calendar/

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]

RewriteRule ^([0-9]+)/?$ load.php?year=$1 [L,QSA]

RewriteRule ^([0-9]+)/([0-9]+)/?$ load.php?year=$1&month=$2 [L,QSA]

RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/?$ load.php?year=$1&month=$2&date=$3 [L,QSA]

Answer 1:

您可以使用:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /calendar/

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]

RewriteRule ^([0-9]+)/?$ load.php?year=$1 [L,QSA]   
RewriteRule ^([0-9]+)/(page)/([0-9]+)/?$ load.php?year=$1&p=$3 [L,QSA]

RewriteRule ^([0-9]+)/([0-9]+)/?$ load.php?year=$1&month=$2 [L,QSA]
RewriteRule ^([0-9]+)/([0-9]+)/(page)/([0-9]+)/?$ load.php?year=$1&month=$2&p=$4 [L,QSA]

RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/?$ load.php?year=$1&month=$2&date=$3 [L,QSA]
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(page)/([0-9]+)/?$ load.php?year=$1&month=$2&date=$3&p=$5 [L,QSA]


文章来源: get value with calendar and pagination htaccess