• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Regular expression help needed

I need to construct a regex for Apache's RedirectMatch. I need the following:


RedirectMatch /somepath/to/some/directory/(.*)\.*rpm$ http://www.somedomain.com/$1/mydirectory/$2.rpm

Where the first * should redirect to a certain directory with the same name and the second * should be whole file:

Example:

~/directory/myfile.i386.rpm should go to http://myotherdomain/directory/i386/myfile.i386.rpm

or

~/directory/myfile.i686.rpm should go to http://myotherdomain/directory/i686/myfile.i686.rpm

What's the correct syntax?

0
nigg
Asked:
nigg
  • 2
1 Solution
 
jlevieCommented:
I've not tried this on a web server, but it seems to me that you'd want to do:

RedirectMatch /path/to/directory/(.*)\.(.*)\.rpm http://www.domain.com/directory/$2/$1.$2.rpm
0
 
niggAuthor Commented:
Know what? That's exactly what I did, however it did not work...I'll try it again...maybe I missed a dot somewhere...
0
 
niggAuthor Commented:
Got it! Thanks to your input, I knew, where to look....and was sure now: I had in the URL a $ sign, which I had to escape...now it works! Thanks....
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now