I've got a blog set up in www.foo.com/wordpress/ and would really like all demands which go to the page that does not begin with /wordpress/ to become rerouted to www.foo.com/wordpress/ (without upkeep from the URL).

E.g.:

www.foo.com/bar/baz/hello.gif     > www.foo.com/wp/

Also, simultaneously, I want the Hyperlink to have www. added whether it does not (which can be where my rules are becoming confused)

Right now, I've:

RewriteCond %{HTTP_HOST}      !^www.foo.com [NC]
RewriteCond %{HTTP_HOST}      !^$
RewriteRule ^/(.*)            http://www.foo.com/$1 [R=permanent]

RewriteRule ^(?!wp)/(.*)$               http://%{HTTP_HOST}/wp/($2) [R=permanent]

However I think this really is presently completely damaged.

Help much appreciated.

RewriteCond %{HTTP_HOST}      !^www.foo.com [NC]
RewriteCond %{HTTP_HOST}      !^$
RewriteRule (.*)              http://www.foo.com/$1 [R=permanent,L]

RewriteRule ^(?!wp/)(.*)      http://%{HTTP_HOST}/wp/$1 [R=permanent]
  1. The road area of the URL being matched up never includes a leading slash, and you don't have to anchor a .*.
  2. L modified prevents spinning from ongoing once you get to the first redirect.
  3. Negative-lookbehind (?!) isn't a taking construct, and also you substitute in taken designs by writing $1, not ($1).

Edit: Apparently for OP the final rule does not work, neglecting to exclude the instances that start with /wp/, making no sense in my experience but whatever. Here's an effort in a workaround:

RewriteCond %{HTTP_HOST}      !^www.foo.com [NC]
RewriteCond %{HTTP_HOST}      !^$
RewriteRule (.*)              http://www.foo.com/$1 [R=permanent,L]

RewriteCond %{REQUEST_URI}    !^/wp/
RewriteRule (.*)              http://%{HTTP_HOST}/wp/$1 [R=permanent]

Try these rules:

RewriteCond %{HTTP_HOST} !^www.exmaple.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^ http://www.example.com%{REQUEST_URI} [R=301,L]

RewriteCond %{THE_REQUEST} ^GET\ /wp/
RewriteRule ^wp/(.*) /$1 [R=301,L]

RewriteRule !^wp/ wp%{REQUEST_URI} [L]

The very first rule is perfect for the host title. The second reason is to get rid of the /wp path prefix externally. And also the third would be to add the prefix again for internal redirection.