I am not good at something that requires regular expressions - including redirects.

I have to redirect all subpages to particular subpage. Everything I have attempted either fails or causes an infinite redirect loop.

Example: Say I would like everything underneath the domain to redirect to www.test.com/fubar (but clearly not /fubar)

This appears like it ought to be quite simple. Anybody?

[Update]

I have attempted everything published to date, and absolutely nothing works. What is happening would be that the pages aren't redirecting as well as not loading stylesheets. It has something related to the relaxation from the htaccess file, which consists of stuff for WordPress:

RewriteEngine On

RewriteBase /

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

I'd say something similar to this:

# Don't rewrite anything in /fubar
RewriteRule ^fubar - [L]
# Redirect everything to /fubar
RewriteRule ^(.*)$ /fubar/$1 [R=301,L,QSA]
RewriteEngine On
RewrteRule !^/?fubar$ /fubar

What you would like:


RewriteEngine On
RewriteRule ^fubar/ - [L] // protect from loop, not sure if its really necessary
RewriteRule ^.*$ fubar/$0 [L,QSA]

How to redirect only when the file path as given in the user doesn't exist:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ fubar/$0 [L,QSA]

This really is simpler to complete using proxies:

ProxyRequests Off
<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
ProxyPass / http://www.test.com/fubar/
ProxyPassReverse / http://www.test.com/fubar/