Thank you for your response, Tom, You are correct in that I don't expect the server to alter the HTML output. I want to tell the server to fetch a file at an arbitrary path if it receives a request for an absolute URL. So, for example, say I have <img src="/example/path" />, I want to use a a rule in an .htaccess file to fetch the file at an arbitrary path, say "/prefix/example/path" or "prefix.url/example/path", etc. I do not want to change the global server settings, VirtualHost settings and/or raw web pages. Alternately, I want to be able to have a page with <a href="/example/path">link</a> and, when a user clicks on "link", be directed to an arbitrary location. I forget that "//" denoted a protocol-independent URL, so thank you for telling me. Again, I can use rewrite rules to rewrite relative and protocol-independent URLs and get the file I want. However, even with error logging turned up to the trace8 level, I cannot see absolute URLs going into the rewrite rules in my .htaccess file. All I see, from access.log, is the server trying to fetch the file from the absolute URL (as you indicated in point 3 in your response) and returning a 404 error because there is no file there (which is why I want to rewrite it). I hope that's clearer. With thanks, Borden On 20 November 2013 06:23, Tom Evans <tevans.uk@xxxxxxxxxxxxxx> wrote: > On Tue, Nov 19, 2013 at 11:06 AM, Borden Rhodes <jrvp@xxxxxxxxxxxxxxxx> wrote: >> Good morning, list, >> >> After about 7 hours of struggling with this issue, I can't seem to >> find out how to trace the cause of this issue: >> >> I am trying to rewrite absolute URLs using a .htaccess file on my >> computer being served from localhost. I have succeeded in the >> following: >> Using, say, an HTML file containing the tag <img >> src="//www.example.com/image.png" />, I used "RewriteRule >> ^//(.*example\.com.*) http://$1" to get Apache to fetch the image; >> Using an HTML file containing the tag <img >> src="www.example.com/image.png">, I used "RewriteRule >> ^(.*example\.com.*) http://$1" to get Apache to fetch the image; >> >> However, using an HTML file containing the tag <img >> src="/www.example.com/image.png"> and "RewriteRule >> ^/(.*example\.com.*) http://$1", the webpage does not show the image. >> Further, turning the LogLevel up to trace8 and picking through >> error.log only shows that Apache failed to fetch the image from my >> file system (that is, /home/borden/www.example...) and didn't even >> pass the URL to the RewriteRule. >> >> Could someone explain why absolute URLs (which is what I'm simulating >> here) aren't getting caught by RewriteRule? The real problem I'm >> trying to solve involves needing to play with Drupal in a subdirectory >> of my localhost machine without changing any of the links. Therefore, >> suggestions to "rewrite the <img> tags" won't help. I ran the example >> from a simple website I set up in a folder on my server, not the >> Drupal installation. >> >> With thanks, >> >> Borden Rhodes >> > > Hi Borden > > It's unclear from your email what you are expecting mod_rewrite to do. > In particular, you talk about <img> tags, but mod_rewrite does not > alter the HTML that is output, it alters the URL requested so that it > can be mapped to a different resource. > > You mentioned three different URLs presented in the HTML, all of which > have very different meanings: > > //www.example.com/image.png (1) > www.example.com/image.png (2) > /www.example.com/image.png (3) > > (1) is a protocol independent URL. Your browser will use whatever > protocol the page this is referenced in to request this URL, and > connect to www.example.com and request the resource /image.png > > (2) is a relative URL. Your browser will take the protocol, host and > URL of the page this is referenced in and append the relative URL. Eg, > if the current page is http://foo.com/bar/, then your browser will > connect to foo.com and request the resource > /bar/www.example.com/image.png > > (3) is an absolute URL. Your browser will take the protocol and host > of the page this url is referenced in and request the resource > specified. Eg if the current page is http://foo.com/quuz/, then your > browser will connect to foo.com and request the resource > /www.example.com/image.png > > Can you try to explain what URLs you are receiving - check your access > log - and what URL those requests should be rewritten to. > > Cheers > > Tom > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx