Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to redirect any url I visit on my computer (Mac), say[\d]+, to another url[\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
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


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.