On Tue, Nov 19, 2013 at 11:06 AM, Borden Rhodes <j...@bordenrhodes.com> 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-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to