我的日历分页就像这样
example.com/calendar/2014/page/2
example.com/calendar/2014/04/page/2
example.com/calendar/2014/04/05/page/2
有人去/page/
没有最后号码我想重定向而没有/page/
...我想要这样的类型..如果有人可以帮我这个。
Note : i want 301 redirect
我想像这样重定向
example.com/calendar/2014/page/(使用斜杠或不斜杠) - > example.com/calendar/2014
example.com/calendar/2014/04/page/(使用斜杠或不斜杠) - > example.com/calendar/2014/04
example.com/calendar/2014/04/05/page/(使用斜杠或不斜杠) - > example.com/calendar/2014/04/05
这是我的代码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]+)/(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]
答案 0 :(得分:1)
将此301规则插入现有的第1个www
强制执行301规则之下:
RewriteCond %{THE_REQUEST} \s/+(.+?)/page/?[\s?] [NC]
RewriteRule ^ /%1? [R=301,L]