Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have 3 URLS all pointing to the same site.


I have a folder /foo/bar which has lots of sub folders and files in etc. I want to rewrite this to /bar.

So if I have I want it to redirect to Is this possible?

Sometime I may have a URL like so this would become Only the first instance of foo would be rewritten.

share|improve this question

Yes this is possible. You have to use mod_rewite, which I don't know to much about. Maybe this link will help you:

share|improve this answer

This should be the first step for achieving it:

RewriteEngine On
RewriteRule ^foo/(.*)$ $1 [R]

Still it has a problem – it will redirect URL "/foo/foo/foo/bar/a.html" to "/bar/a.html" as well.

share|improve this answer

Your Answer


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