Marco
Marco

Reputation: 2737

.htaccess rewrite for date like YYYY-MM-DD

I'm trying to write a rule for a date (YYYY-MM-DD)

domain.com/2017-11-17

I did some research here and I came up with this:

RewriteRule ^image-day/([0-9]{4}+-[0-9]{2}+-[0-9]{2})/?$ admin.php?do=image_day&date=$1 [L]

It seems to work, but I was wondering if there is a better or more robust way to do it.

Can i improve on my rule?

Upvotes: 0

Views: 774

Answers (1)

Croises
Croises

Reputation: 18671

You can use:

RewriteRule ^(\d{4}-\d{2}-\d{2})/?$ admin.php?do=image_day&date=$1 [L]

And in this case, you can put the date at the root, as in your question.

Upvotes: 2

Related Questions