Forum Moderators: phranque
Am running Apache-2.0+ on FBSD-6.2px
I do all rewrites in the httpd.conf
Problem is that I have 10-12 existing files named like:
cdrom1.htm
cdrom2.htm
.........
cdrom12.htm
I need to redirect all of the above requests for the existing files to only cdrom.htm
Reading some other redirects, I took several shots at it over the past hour or so and nothing works so far. So, how would I do this?
RewriteEngine On
redirect from: http://www.example.com/folder/cdrom[0-9]+.htm$
to: http://www.example.com/folder/cdrom.htm$
BTW: Have not used the above lines, but just explains what I'm trying to do.
Thanks for any tips!
Really enjoying the forums.
TxJack
[edited by: jdMorgan at 1:18 am (utc) on Aug. 29, 2007]
[edit reason] example.com [/edit]
You are nearly spot on with your rule. You don't need to use the $ symbol to specify the end of the string in the URL to redirect to. A (hopefully!) working rule is below:
RewriteRule ^folder/cdrom[0-9]+.htm$ /folder/cdrom.htm [R=301,L]
So you'll need a leading slash:
RewriteRule [b]^/f[/b]older/cdrom[0-9]+[b]\.h[/b]tm$ http://www.example.com/folder/cdrom.htm [R=301,L]
Jim