[CentOS] apache rewrite

Tue Aug 17 17:50:44 UTC 2010
Les Mikesell <lesmikesell at gmail.com>

On 8/17/2010 12:14 PM, Craig White wrote:
> Is there some easy way to rewrite just the base URL to another URL but
> leave all other URL's unmolested?
>
> i.e.
>
> http://www.example.com  = rewrite to another URL
>
> http://www.example.com/files = deliver from the assigned subdirectory
>
> obviously this...
> Redirect / http://www.other_url.com
> redirects everything
>
> and I don't want /files to be redirected


If you are using RewriteRules, you can use the [PT,L] flags to force 
matches to be handled immediately without changes or checking for 
additional matches, so:
RewriteRule  ^/files - [PT,L]
would make everything under /files be handled from the original location 
regardless of subsequent rewrites.  ^/* would probably work too.

Then you can use
RewriteRule  ^/$  http://www.other_url.com [R,L]
for the redirect.   This approach makes it fairly easy to mix and match 
content from old/new locations during a transition.   Or you can proxy 
some pages with the P flag if you don't want to expose the new location.

-- 
   Les Mikesell
    lesmikesell at gmail.com