I’m no good at anything that requires regular expressions – this includes redirects.
I need to redirect all subpages to a particular subpage. Everything I’ve tried either fails or causes an infinite redirect loop.
Example: Say I want everything under the domain to redirect to www.test.com/fubar (but obviously not /fubar)
This seems like it should be super easy. Anyone?
[Update]
I’ve tried everything posted so far, and nothing works. What’s happening is that the pages are not redirecting and also not loading stylesheets. I think it has something to do with the rest of the htaccess file, which contains 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 like this:
What you want:
Now to redirect only if the file path as given from the user does not exist:
This is easier to do using proxies: