So I guess you guys are getting pretty fed up of answering questions about mod_rewrite, but here's another one to add to the pile.

So I'm working on a new version of a site that's currently running (Lets call it mysite.com). Any visitor to http://mysite.com/ will be visibly redirected to http://mysite.com/oldsite/ but only if they access http://mysite.com/ directly (I.E. mysite.com/somefile will throw 404).

My current .htaccess is

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ newsite/$1 [L]
</IfModule>

I want my new site to work at the root URL and I'm working at http://mysite.com/newsite/. When the new site goes live I want http://mysite.com/ to back-end redirect to http://mysite.com/newsite/ (Not a problem, sorted that fine) but I also want http://mysite.com/file.htm to back-end redirect to http://mysite.com/newsite/file.htm (Also not a problem). The issue comes when http://mysite.com/newsite/file.html does not exist, the server goes into an infinite loop of redirects ending in a 500 error.
So basically I want to redirect all not-found files to http://mysite.com/newsite/ unless they are already in /newsite/.
I guess its something to do with RewriteCond but I'm not smart enough to figure it out for myself =]
-Sam

Doh! Forgot mod_rewrite uses RegEx so I just did

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!newsite)(.*)$ newsite/$1 [L]
</IfModule>

I'll go take my stupid somewhere else for a bit =D
-Sam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.