Forum Moderators: phranque
I have some file names such as
example.com/filename1.html
example.com/filename2.html
and so on...
Though I can set up 301 redirects for individual file names such as
redirect 301 /filename1.html http://www.example.com/
redirect 301 /filename2.html http://www.example.com/
I was wondering if there can be a rule set that would redirect all the series of files from /filename1.html to /filename9.html at one go to the root domain.
I tried this one, but doesn't work:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^/filename([0-9])\.html http://www.example.com/ [R=301,L]
Thanks in advance!
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^filename([0-9])\.html http://www.example.com/ [R=301,L]
RewriteRule ^(filename[0-9]+\.html)$ http://www.example.com/$1 [R=301,L]
PS: Just didn't notice this was exactly your intent to 301 redirect all to the root index. So, your rule would be okay.