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

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

2 Answers 2

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.