Forum Moderators: phranque
I am having difficulty structuring the correct RewriteRule to achieve what I want. Basically I have a year/month/day directory with folders in it i.e. [example...] I want my rule to redirect users who try to access [example...] for example, and at the levels, "2009", "03" also, but my rule just redirects everything below 2009 so far. The folders sitting beneath ../26/ all have index files in them (don' want redirected), and it is inneficient to redirect day folder manually using a script. How do I do this?
Thanks in advance.
RewriteEngine on
Redirect permanent /2009/ http://www.example.com
Unfortunately this does anything below 2009/... I want the 2009 (year) level, the 03 (month) level, and the 26 (day) level, but not the folders within the day level.
Thanks.
RedirectMatch 301 ^2[0-9]{3}((/0[0-9]¦/1[012])(/[012][0-9]¦/3[01])?)?/?$ http://www.example.com/
Jim
You don't "redirect" people to a 404 page. The 404 page simply 'appears' for the current requested URL if that URL does not exist.
You won't be able to use Redirect here, as you'll need a certain amount of pattern matching to take place. Look at RewriteRule intead, but again, I wouldn't redirect these all back to the root index page.