Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm looking for a way to redirect any url I visit on my computer (Mac), say www.example1.com/a/b/[\d]+, to another url www.example2.com/a/[\d]+. I don't want this to be on the IP level, just for that particular URL matched by a regular expression.

/etc/hosts was my first idea, but unsure how to do the regex match to capture the numbers and pass it to the second URL defined.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can't do this in a hosts file as it is purely an IP-to-name mapping. It either needs to be done on the web server, or on a proxy server.

Apache will allow you do to this with mod_rewrite and Squid will allow you to do it with redirectors.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.