Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

I have a folder ~/Branches/ that is accessible via apache2 at localhost/~me/. Now I have localhost/~me/branches_index/web/index.php that I would like to make available at localhost/~me/branches_index/

So how can I redirect from /~me/branches_index/ to /~me/branches_index/web/ from the /Branches/branches_index/ folder?


I tried, but I did not succeed.

Endless loop:

Redirect /~me/branches_index/ /~me/branches_index/web/

Put /web/ at the front:

Redirect / /web/
link|improve this question
Your question isn't really a duplicate of the mod_rewrite question, but you'll find more details on how to do what you want over there :) – voretaq7 Mar 3 at 7:03
feedback

closed as exact duplicate by SvenW, MadHatter, Ward, MDMarra, voretaq7 Mar 3 at 7:02

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

The redirect you're attempting is failing because
Redirect /~me/branches_index/ /~me/branches_index/web/
will redirect everything from /~me/branches_index/* recursively.

That means /~me/branches_index/what/so/ever
will be redirected to /~me/branches_index/web/what/so/ever thus you end up in an endless cycle.

The solution is to use rewrite in .htaccess file, saved at /~me/branches_index/.
Something like this code should do the work:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^(.*)web/(.*)$
RewriteRule ^(.*)$ /~me/branches_index/web/$1 [NC,L]
link|improve this answer
feedback

One way would be to put this in the or .htaccess configuration for /branches_index/

RewriteEngine On
RewriteCond %{REQUEST_URI} !^web/
RewriteRule (.*) web/$1 [QSA,L]
link|improve this answer
feedback

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