I'm hosting a few domain names of the identical wordpress installation, now Let me possess a per-domain folder for many various files I have to put available online for.

Basically I wish to map such as this:

URL                     Path

webbfarbror.se/f/*      _files/webbfarbror.se/*

grapefrukt.com/f/*      _files/grapefrukt.com/*

This little snippet does the task nicely and also the RewriteCond let us me enable and disable this on the per domain basis.

ReWriteCond %{HTTP_HOST} webbfarbror.se
ReWriteRule ^f/(.*)$ _files/%{HTTP_HOST}/$1 [L]

However, personal files at say, http://grapefrukt.com/f/awesome.jpg can also be accessible at it's "real" URL http://grapefrukt.com/_files/grapefrukt.com/awesome.jpg

My attempts lead to infinite redirects backwards and forwards.

How do you disable access with the latter URL?

You can even examine the initial request because it was delivered to the server, that is available as %{THE_REQUEST}. Checking for that /_files/ prefix signifies the request was from the latter type, and you will then redirect towards the appropriate format:

RewriteCond %{THE_REQUEST} ^[A-Z]+\s/_files/
RewriteRule ^_files/[^/]+/(.*)$ http://%{HTTP_HOST}/f/$1 [R=301,L]