Forum Moderators: phranque

Message Too Old, No Replies

htaccess to deliver day specific page

rss feeds delivered by htaccess

         

richard2006

6:41 pm on Apr 2, 2006 (gmt 0)



Hi there - my site's RSS feed is publicised as "myfeed.xml", but I have 7 different feeds, one for each day of the week.
So, how do I get "myfeed.xml" to deliver "sun.xml" on a Sunday etc? Would the following in an .htaccess do the trick? many thanks! R

RewriteEngine on
RewriteCond %{TIME_WDAY} 0
RewriteRule ^myfeed\.xml$ sun.xml
RewriteCond %{TIME_WDAY} 1
RewriteRule ^myfeed\.xml$ mon.xml
RewriteCond %{TIME_WDAY} 2
RewriteRule ^myfeed\.xml$ tue.xml
RewriteCond %{TIME_WDAY} 3
RewriteRule ^myfeed\.xml$ wed.xml
RewriteCond %{TIME_WDAY} 4
RewriteRule ^myfeed\.xml$ thu.xml
RewriteCond %{TIME_WDAY} 5
RewriteRule ^myfeed\.xml$ fri.xml
RewriteCond %{TIME_WDAY} 6
RewriteRule ^myfeed\.xml$ sat.xml

extras

7:18 pm on Apr 2, 2006 (gmt 0)

10+ Year Member



If you name the files as myfeed-0.xml to myfeed-6.xml instad of sun.xml ...sat.xml, you can do it like this, I guess.

(Codes not tested)

RewriteEngine on
RewriteBase /
RewriteCond %{TIME_WDAY} ^(.*)$
RewriteRule ^myfeed\.xml$ myfeed-%1.xml [L]

Or similar to your code, but in one RewriteRule
RewriteEngine on
RewriteBase /
RewriteCond %{TIME_WDAY}sun ^0(.*)$ [OR]
RewriteCond %{TIME_WDAY}mon ^1(.*)$ [OR]
RewriteCond %{TIME_WDAY}tue ^2(.*)$ [OR]
RewriteCond %{TIME_WDAY}wed ^3(.*)$ [OR]
RewriteCond %{TIME_WDAY}thu ^4(.*)$ [OR]
RewriteCond %{TIME_WDAY}fri ^5(.*)$ [OR]
RewriteCond %{TIME_WDAY}sat ^6(.*)$
RewriteRule ^myfeed\.xml$ %1.xml [L]