replace hotlinked image with html code - .htaccess

I found out a competitor of mine copied my webpage and in the process hotlinked an image on his page - he probably just copy/pasted from the browser.
I know how to handle hotlinking, but I want to attempt a better version of it: I want to replace the http://www.mysite.invalid/image.jpg on his page with html code using htaccess so when his page with the html
<img src="http://www.mysite.invalid/image.jpg" />
would be replaced by
dontstealbandwidth.jpg"/> this image steals bandwidth from mysite.invalid<img src="dontstealbandwidth.jpg
The result in his page would then be
<img src="http://www.mysite.invalid/dontstealbandwidth.jpg"/> this image steals bandwidth from mysite.invalid<img src="dontstealbandwidth.jpg" />
I tried to redirect the image to an html file. Directly accessing the image on my site will show the content of the html file. However this does not seem to work on images inside html code.
Is this at all possible? It feels like it shouldn't be but it would be cool if it would be.
Is it at all possible to do this?

When a browser is requesting image data then you cannot return HTML text in response. You can of course make a custom image named /dontstealbandwidth.jpg with your HTML text embedded in it and redirect /image.jpg to /dontstealbandwidth.jpg using simple redirect rule like this:
RedirectMatch 301 ^/image\.jpg$ /dontstealbandwidth.jpg

Related

How to access images from a HTML page

how to access images from a html web page.
I am a newbie for linux and trying to learn
I have images in this location /shutterfly/web/htdocs/images
how to embed the image link in the html source code . anything I need to update in the httpd.conf file or .htaccess file
www.example.com/images/facebook.jpg
scenerio below in the source code
thanks
Raj
Can you explain you problem more nicely please.
I mean what's different in linux for adding images in html code.
We always use <a href = ""> for adding links or locations of images.
please explain your problem once more.

How to scrape image in ion-img if the src is php script which is generating captcha code

I'm scraping website for the college project which will be used to display the result.
The problem is the results are protected by a captcha code.
I tried scraping using the node HTML parser but when I extract src attribute it says captcha.php.
Inspect element of that captcha code image is below
<img src="captcha.php" class="control-label ">
const img = <HTMLElement[]><any>root.querySelectorAll('img') ;
console.log(img[1]);
let imgt1 =<HTMLImageElement> img[1];
let tmp3 =JSON.stringify(imgt1.attributes);
et con1 = JSON.parse(tmp3)
console.log(con1)
this.image= con1;
console.log(this.image.src)//output captcha.php
at the front end
<ion-img [src]="image.src"></ion-img>
and the front end image is not displaying and it showing broken image
what should I do?
edit:
website also uses cookies also 'PHPSESSID'
Just because the url of the element is pointing at a php file doesn't mean it's returning a php web page.
You can write php to return any type of data you want. In this case its returning an image.
You can try downloading the captcha.php file. In theory it should have an image contents inside of it but probably it will detect that the script is not being called from the right location and show some kind of error image.
The point of a captcha is to specifically stop this kind of thing. You are a robot trying to access the system. If it was a simple case of pulling the image out via a script then it would make the captcha system pretty pointless.
When you say this is for a college project, what do you mean? Is the project to try to break a captcha system? Or are you just trying to cheat somehow?

SVG file with xlink to another page in AMP project

I have an SVG file containing a number of xlinks that navigate to a different page. For example:
<a xlink:href="us/ak">...</a>
The SVG is a US map, and I'd be happy to provide it, but it's too big to include here.
When I try to use this SVG in an AMP page, the xlinks don't work. I see in the AMP spec that xlinks in an SVG are required to have a target URI starting with "#", so I think that's why my xlink isn't working. It behaves the same whether I use an amp-img or img tag.
It works fine if I put it in an img tag on a non-AMP page.
Is there a way to get my links to go to a new page, and not just to a #-link on the same page?
The color change on hover also stops working when I put the SVG on an AMP page, but I'm tackling one problem at a time.
If you just want to link to another page, <a href="..."> should work...

.htaccess to redirect images

i'm still new to the redirectrule thing from htaccess and have successfully redirected my pages so that the pretty URL shows up, but is there a way to redirect the images so that it is not relative? Is there a way or function that allows me to redirect images without changing it one by one ?
Like i after redirecting the page, i get relative URL, hence my images are showing something extra in their links.
so this is the actual url to the image
http://www.yousite.com/page/images/this.jpg
but i'm getting stuff like
http://www.yoursite.com/images/page/images/this.jpg
I am not sure this will solve the problem, but instead of modifying all the links you could use the BASE element in each page to define a base URI:
From http://www.w3.org/TR/html4/struct/links.html#h-12.4:
When present, the BASE element must appear in the HEAD section of an
HTML document, before any element that refers to an external source. The
path information specified by the BASE element only affects URIs in the
document where the element appears.
Examples:
<HEAD>
<BASE href="ImagesBasePath">
</HEAD>
Or just:
<HEAD>
<BASE href="/">
</HEAD>

Using an animated GIF in a Dialog loading screen. JSF 1.1

This problem is the result of IE7 not displaying animated GIF's that are hidden.
for reference:
http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif
These 2 solutions involve the use of the setTimeout function and innerHTML. These examples use absolute URL's to the images. Since I'm using JSF, I would like to use relative URL's. Is there a proper way to do this in JSF?
Those examples doesn't use absolute URL's. Your problem lies somewhere else. At least, the URL pointing to the image should be relative to the request URL of the JSF page in question. You can easily check it in the browser's address bar.
A common mistake among starters is namely that they think that it should be relative to the location of the page in the server side folder structure. This is untrue. You should look at the request URL. Determine the absolute request URL of both the JSF page and the image, then you should be able to extract the relative URL to the image from it.

Resources