Lets say I have a two websites http://www.sample.com and files.sample.com.
In an .htaccess file within the webroot of http://www.sample.com, I have the following:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{QUERY_STRING} ^files\/uploads [NC]
RewriteRule ^(.*)$ http://files.website.com/$1 [NC,L]
</IfModule>
The desired result is to have all requests of www.sample.com/files/uploads/file.xml or www.sample.com/files/uploads/subfolder/file.json get 302 redirected to files.sample.com/files/uploads/file.xml and www.sample.com/files/uploads/subfolder/file.json, respectively.
However, I can’t get the rule to fire. The directory “files” does not exist on the http://www.sample.com website at all.
Could anyone give me a little help as to why the
You probably want REQUEST_URI not QUERY_STRING.
Also note the leading slash.