RewriteEngine On RewriteOptions MaxRedirects=3 RewriteCond %{REQUEST_URI} !^/$ RewriteCond %{DOCUMENT_ROOT}/root%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/root%{REQUEST_URI} -d RewriteCond %{REQUEST_URI} !^/some_dir RewriteRule !^/?root/ /root%{REQUEST_URI} [PT,L] RewriteCond %{REQUEST_URI} !^/?script/testapp_fastcgi.pl RewriteRule !^/?root/ script/testapp_fastcgi.pl%{REQUEST_URI} [L]