David,
If we were talking RewriteRule you would be completely correct. However, we are talking about matching %{REQUEST_URI} in a RewriteCond.
In that case there is a leading slash, in both Apache 1.x as well as 2.x
If you don’t believe me, try this
RewriteEngine On
RewriteCond %{REQUEST_URI} !test
RewriteRule .? /test?q=%{REQUEST_URI} [R=301]
and browse to /blah; you’ll be redirected to /test?q=/blah
I did not type that / and it’s not in the RewriteRule, so it must be in the %{REQUEST_URI}.
If it’s in the {REQUEST_URI}, I must put it in my test when I check against it in a RewriteCond.
If that does not convince you, the manual says (here):
It says the same in manual for 1.3, see Apache module mod_rewrite
I tested this on Apache 2 on Win7 Ultimate (WampServer 2)
What? Where did you get that info?
When I put the following in my .htaccess (yes, I know it’ll loop)
RewriteRule .? http://%{HTTP_HOST} [R=301]
and use HTTP Live Headers in FireFox to look at the raw HTTP Headers, it says
http://sp/
GET / HTTP/1.1
Host: sp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.7,nl;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
HTTP/1.1 301 Moved Permanently
Date: Sat, 20 Aug 2011 00:46:55 GMT
Server: Apache/2.2.17 (Win32) PHP/5.3.5
[B][COLOR="Red"]Location: http://sp[/COLOR][/B]
Content-Length: 217
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
Note that Apache did ~not~ add a / at the end of %{HTTP_HOST}, it’s just [noparse]http://sp[/noparse] without a tailing slash …