.htaccess redirect all urls not beginning with /foo/

I have one question :

I want to redirect all URLS of my website which not begin with /foo/.
Some exemple :

/page.html -> /foo/page.html 
/foo1/page.html -> /foo/foo1/page.html

Actually I have that :

RewriteCond %{REQUEST_URI} !^/foo/
RewriteRule (.*) www.example.com/foo/$1 [QSA,L,R=301,NC]

But I have an error.

Thanks for your help !

Source: apache

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.