tags:

views:

23

answers:

1

Hi, I have a simple redirect which I just can't get to work and I don't know what's wrong. The server's throwing me a 500 Internal Server Error for no reason I can understand.

I'm trying to achieve the following: if a user types the address www.example.com, it will actually be routed to domain/ subdirectory in my server. So if user requests www.example.com/index.htm, it would fetch the file from /var/www/html/domain/index.htm.

Here's what I have so far:

RewriteEngine On
Options +FollowSymlinks

RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^(.*)$ domain/$1 [L]

Mod_rewrite is enabled and functional, as this does work:

RewriteRule ^(.*)$ domain/index.php?$1 [L]

What am I missing here?

+3  A: 

You have to exclude the destination you want to redirect to:

RewriteCond %{SERVER_NAME} =www.example.com
RewriteCond $1 !^domain/
RewriteRule ^(.*)$ domain/$1 [L]

Otherwise you will get an infinite recursion since domain/… is also matched by .*.

Gumbo
Absolutely marvellous, it's working now. Thanks!
Tatu Ulmanen