Forum Moderators: phranque
With Apache 2.2, my .htaccess:
----------------------------
RewriteEngine On
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*) /redirect.php [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+) /redirect.php [QSA,L]
----------------------------
If I type:
- [mydomain.com...] it works
- [mydomain.com...] I get a 404 error message.
What am I doing wrong?
Thank you very much.
RewriteEngine On
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*) /redirect.php [L]
RewriteRule ^([0-9]+)/([0-9]+)/?$ /redirect.php [L]
The second rule ensures that both /2007/05/ and /2007/05 work, and then the matching stops.
Your current code lets /2007/05/morestuff/morestuff work[1], and perhaps your rules are conflicting in Apache 2.
If you are sure that the format will always be YYYY/MM/DD then you could further restrict it. Using:
([0-9]{4}) & ([0-9]{2}) in place of the ([0-9]+) (The numbers 4 and 2 denote exact 4 and 2 of the preceding range.)
Also, depending on what "foo" really is, you could further restrict that match from (.*).. especially because your code allows [mydomain.com...] to even work.
Why are you using QSA if you have no query strings appended? Hope that helps you a bit.
[1] In Apache 1.3.37, at least.