Smart redirect in .htaccess

Wondering if this is something that can be done in an .htaccess file – to code a “smart redirect” based on current month.


THE BUSINESS NEED:

At the start of each month, I have to manually go into Yoast plugin and set a redirect for

to actually go to the page for the current month, so that people landing on that page see the food days for that particular month first.

Example:

At the very end of February, I manually set a redirect for that /food-calendar link

to be

…/food-calendar/?fwp_FoodMonth=March

At the end of March, I will set it to go to …food-calendar/?fwp_FoodMonth=April

etc.

THE CHALLENGE

I am often too busy or forget, so that sometimes this doesn’t happen until a week or two into the next month.

QUESTION
Is this something that can be programmed in the .htaccess file? A bit of programming so that month number is detected from date, and that if month=1, then URL = …food-calendar/?fwp_FoodMonth=January, if month=2, then URL = …/food-calendar/?fwp_FoodMonth=February, etc?

The server-side code should setup and use the current month if the get parameter doesn’t contain a valid month, i.e. it’s not set, it’s empty, or it’s not a valid month name, otherwise use the supplied month value. Any link you provide on a page for the current month, would simply not have that get parameter in it. If you want to provide links to previous month(s), they would contain the corresponding month name in the get parameter.

Can help you with the solution.
Let me know, If interested

Good Day
Deep

Update: I was able to meet the business need in another fashion. Cheers.

Sponsor our Newsletter | Privacy Policy | Terms of Service