Oy.
What happens with your current htaccess? (Sure, someone could sit down and work it out from studying the lines of code, but it's a lot faster-- and, ahem, less annoying-- if you just say so.)
Here is the logic I want to create:
Welcome to htaccess. It does not work like any other programming language in the world. It is theoretically possible to combine [AND] (default) and [OR] in a single set of Rewrite Conditions, but I do not advise it unless you are rock-certain that you know what you are doing. In other words, don't try it ;)
If the URL is not exactly http://domain.net/robots.txt.
And
Let's start by leaving off the periods, because they have meaning in RegEx-speak, and htaccess is 90% RegEx.
If the URL is not exactly http://domain.net/robots.txt
AND
If the URL
( is exactly
You can stop here, because if the url
is exactly /robots.txt (can we please assume that people who ask for www.domain.net/robots.txt are also allowed in, since that particular rewrite hasn't happened yet?) then by definition it is
not exactly anything else. So you only need to exclude it from those conditions that would potentially allow it.
If the URL
( is exactly http://domain.net
or
is exactly http://domain.net/ )
go to http://domain.net
Um, you want to
delete the trailing slash that your server has just gone to the trouble of adding?
ELSE
If the URL
( begins with http://domain.net/http://bbb )
/* where bbb can be anything */
Say wha? Is that really the form of your urls? How on earth did they get to be that way? Are you mopping up someone else's mistakes?
go to http://domain.net/t/?url=bbb
ELSE
If the URL
( begins with http://domain.net/yyy )
/* where yyy can be anything */
meaning, anything other than http: ?
go to http://domain.net/r/?url=yyy
...
RewriteBase /
Unless you have an extremely wonky server, that's the default RewriteBase and you don't need to specify it.
RewriteCond %{http_host} ^www\.domain\.net [NC]
RewriteRule ^(.*)$ http://domain.net/$1 [R=301,NC]
If they ask for www.domain.net, send them to domain.net. OK. But if you're on shared hosting, check the fine print. You may be able to do this kind of thing by clicking a button, and then you don't have to mess with it in htaccess. One less thing to keep track of.
RewriteCond %{REQUEST_URI} !^/t/
RewriteCond %{REQUEST_URI} !^/r/
RewriteCond %{REQUEST_URI} ^/http:/
RewriteRule ^http:/(.*)$ http://domain.net/t/?url=$1 [R=301,L]
If they don't ask for the /t/ directory, or the /r/ directory, but they do ask for something starting over again in /http:/ then send them to the /t/ directory, replacing the former query string-- if any-- with "url=/" (the second slash in ht
tp:// was included in your capture) and contains the whole remainder of the request.
If they are asking for /http:/ then they are by definition
not asking for /t/ or /r/ so you don't need to say so. But I kinda suspect that mod_rewrite will go bonkers if you try to feed it http:/ anywhere other than the target string or certain versions of {THE_REQUEST}.
:: looking vaguely around for g1 ::
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/robots\.txt$
RewriteCond %{REQUEST_URI} !^/t/
RewriteCond %{REQUEST_URI} !^/r/
RewriteCond %{REQUEST_URI} !^/http:/
RewriteRule ^(.*)$ http://domain.net/r/?url=$1 [R=301,L]
If they ask for something that isn't an existing file, AND isn't an existing directory, AND isn't robots.txt (which presumably does exist, so you don't need to name it again), and isn't any of the same three directories listed above, then redirect them all over again to directory /r/, replacing the former query string-- if any-- with "url=everything they asked for".
Well. That was fun.
Actually I think your htaccess is pretty close, it's just got some lines that don't need to be there, and it isn't in the optimal order.