1

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/
Martin Ueding
  • 237
  • 2
  • 8
  • 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 03 '12 at 07:03

2 Answers2

2

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]
tftd
  • 1,480
  • 7
  • 24
  • 38
1

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]
Devin Ceartas
  • 1,458
  • 9
  • 12