Invisibly rewriting root to subdirectory using mod_rewrite (ajaxplorer)

BT643 picture BT643 · Jun 8, 2012 · Viewed 9.8k times · Source

I've been looking on various sites reading mod_rewrite examples for a few hours, and have used it many times before successfully... but I'm trying something new with it now and can't for the life of me get it working!

I'm using a PHP file manager tool called AjaXplorer, I have it in a subdirectory on the root of my server /ajaxplorer-core-4.0.4. When I go to the root of my site http://domain.com/ I want it to invisibly redirect to the /ajaxplorer-core-4.0.4 folder (but still show the root domain in the address bar).

I still want to be able to access the other files/directories on the root as normal just typing in the path.

I assume this is possible? Seems relatively simple but I just can't get it working.

AjaXplorer seems to load js files and images etc from /ajaxplorer-core-4.0.4/plugins, I have a feeling that's where it's tripping me up.

Any pointers would be massively appreciated! Thanks

Answer

BT643 picture BT643 · Jun 9, 2012

Found it on another answer luckily :)

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www.)?site.com$ 
RewriteCond %{REQUEST_URI} !^/subdir/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /subdir/$1 
RewriteCond %{HTTP_HOST} ^(www.)?site.com$ 
RewriteRule ^(/)?$ subdir/index.php [L]