Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite code to only catch months (numbers) of the year

mod rewrite code to only catch months (numbers) of the year

         

richiebman

1:06 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



Hello. I'm writing my blog and just need a bit of help in making my clean URLs more specific. A typical URL on my blog would be:

/blog/2005/1/post-name

However in decemeber this could be:

/blog/2005/12/post-name2

I have been using the following for the month part of the URL: ([0-9]+). This works, but another feature of the blog is that a user could enter

/blog/2005/1/

and it would display all the posts from january 2005. However they could also put in

/blog/2005/13/ or
/blog/2005/99/

and it wont throw out an error. So is there a way to put an OR statment in mod rewrite code? For example, how would this translate:

/([1-9]) OR ([1][0-2])/

If you can't use an OR statement, how else could I do it?

Cheers,
R

dcrombie

3:21 pm on Jan 31, 2005 (gmt 0)



This should match any number from 1-12 (not tested):

(1[0-2]¦[1-9])

;)

richiebman

4:47 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



Cheers dcrombie. What you put nearly worked but I kept getting 404s, so I swapped the broken pipe (¦) for the un-broken pipe (¦) and that sorted it.

Thanks again,
R

richiebman

4:53 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



Oh well after reading my post again, it seems like this forum replaces unbroken pipes for broken pipes, so you were 100% right first time around ;) .

R