获得日历htaccess的价值

时间:2014-04-27 03:57:49

标签: regex apache .htaccess mod-rewrite calendar

example.com/calendar/2014/4/27 <- i wan to like this from this link example.com/calendar/load.php?year=2014&month=4&date=27
我尝试这样做。但它不起作用..我无法解决它。 这个链接也想要这样

此链接也想工作

  

example.com/calendar/2014

     

example.com/calendar/2014/4

     

example.com/calendar/2014/4/27

我试图喜欢这样做..这里是我的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&date=$3 [L,QSA]

plzz帮助我完成这项工作..谢谢

1 个答案:

答案 0 :(得分:1)

/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]