I have an interesting RewriteRule and I am not sure to make the regular expression.
In short I would like to examine the URL after the second / - based on the contents, possibly forward.
It sums down to these two rules:
- Redirect if string after second / contains any letter
- Redirect if string after second / is longer than 7 characters
Here are examples:
http://www.mysite.org/section/subsection/2011 (OK, do nothing)
http://www.mysite.org/section/subsection/2011-11 (OK, do nothing)
http://www.mysite.org/section/subsection/2011-11-09 (NOT OK, redirect)
http://www.mysite.org/section/subsection/2011-11-W1 (NOT OK, redirect)
Please help me with the Rewrite Rule and Rewrite Cond
As Lane Aasen points out, your examples and rules don't match up. I'm taking your examples to mean that the rules should apply to the 3rd path segment, and suggest the following. You don't say whether the redirect destination is different or not depending which rule matches. I've taken it to be different.
I based the following regex off of your examples which seemed to analyze everything after the last '/' instead of the second.
In plain English, this regex matches a group of characters that follows a '/' and contains 1-7 non-alphabetical characters. To make it only match the last '/' I appended a '$', which matches the end of a line.
Also, since you are dealing with URLs you might want to add "/?" before the '$' in case there is a dangling '/' at the end.
I hope this answers your question.