How would I write a rewrite rule to catch all files and folders in the directory news?
You can use this rewrite rule:
RewriteEngine On
RewriteRule ^news/((?:1989|199[0-9]|200[0-9]|201[0-4])/.+)$ /new/$1 [L,NC,R]
Question
I have multiple directories whose files I need to be redirected to the same location.
For instance:
www.mysite.com/news/1998/1998a.htm
www.mysite.com/news/1998/1998b.htm
www.mysite.com/news/1999/1999a.htm
www.mysite.com/news/1999/1999b.htm
...
There are 250+ of them. It seems like there ought to be a way to shorten
How would I write a rewrite rule to catch all files and folders in the directory news
?
Solution
How would I write a rewrite rule to catch all files and folders in the directory news?
You can use this rewrite rule:
RewriteEngine On
RewriteRule ^news/((?:1989|199[0-9]|200[0-9]|201[0-4])/.+)$ /new/$1 [L,NC,R]