views:

98

answers:

2

I need to point the root domain of my hosting account to a subdirectory (joomla). I want this to be invisible (i.e. browser address bar doesn't change). Also, I need this to work when a user hits the root or a subfile/subfolder.

I've tried the following rules, which work individually, but I can't get them to work together.

This one works when no subfile/subfolder is specified:

RewriteEngine On
RewriteRule ^$ /joomla/ [L]

And this one works when a subfile/subfolder IS specified:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+)$ /joomla/$1 [L]

I just can't figure out how to combine them.

A: 
RewriteEngine On

RewriteRule ^(.*)$ /joomla/$1 [L]

Should work (untested). The key difference between this and your second attempt is the + vs *. The + will match one or more, whereas the * will match 0 or more, so this should work also when no file/subdirectory is specified.

Mailslut
That one throws a 500 server error with or without file/folder. When I add "RewriteCond %{REQUEST_FILENAME} !-f" it works with the file/folder specified, but throws a 500 error without.
dosboy
A: 

This should do the trick:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /joomla/$1 [L]

.* will also match an empty string. You also more than likely want to do the -d check to make sure that they aren't accessing a directory that exists (though, thinking about it, this might mess with the / matching, I don't know).

Matthew Scharley
Works for the file/folder, but the root never redirects. Just gives me a directory listing. Without the -d line it throws a 500 error when hitting the root.
dosboy